Search code examples
zingchart

ZingChart bar chart doesn't show first string value from array


I use ZingCharts for my dashboard charts and I am stucked on this problem. I made a codepen to show my problem. I got array of strings which represent average respond time for some task in hours and I cant figure out why my chart never show 1st string value of array as you can see on codepen.

Here i also post my angular function for this chart

 //bar chart with average task time respond
        $scope.avgRespondTaskTime = {
            gui: {
                contextMenu: {
                    empty: true,
                }

            },
            type: 'bar',
            legend: {
                //width: "100%",
                layout: "center",
                position: "50%",
                margin: "0px 0px 0px 0px",
                borderColor: "transparent",
                backgroundColor: "transparent",
                marker: {
                    borderRadius: 10,
                    borderColor: "transparent"
                }
            },
            tooltip: {
                text: "%v hours"
            },
            "scale-x": {
                "label": { 
                    "text": "Project name",
                },
                "labels": projectNames
            },

            "scale-y": {
                "label": { 
                    "text": "Average Time",
                },
            },
            series: [
             {
                 text: "Completed in Time",
                 values: $scope.avg_respondTime,
                 backgroundColor: "#00a65a"
             },            
            ]
        };

https://codepen.io/spsrulez/pen/ygEvNg


Solution

  • So I solved my problem with using moment.js using this function

    moment.duration("your string represent time").asHours()

    which I store into array $scope.avg_respondTime

    Hope it helps someone in future.