Search code examples
javascriptjqueryangularjsjqplot

JQPlot not using the correct dates


I'm drawing a graph using jqplot but it's plotting against the wrong date. see the code snippet and image below.

else if(rtype === "DATE AXES"){
    $scope.pl = [[]];
    for (var i = 0; i < plotVal.length; i++) {
        console.log(plotVal[i].x+", "+plotVal[i].y);
        $scope.pl.push([new Date(plotVal[i].x), plotVal[i].y]);
    }
    var data = $scope.pl;
    console.log("data: ");
    console.log(data)
    jQuery.jqplot("chartdiv",  [data],
        { 
            axes:{
                xaxis:{
                    renderer:$.jqplot.DateAxisRenderer,
                }
            },
            series:[{color:'#5FAB78', markerOptions:{style:'square'}}],
        });
} 

Any idea what's wrong?

image


Solution

  • Found the problem. It's the pl array in the code; passed an empty value into it first, so it distorted the arrangement

    $scope.pl = [[]];
    

    was suppoed to be:

    $scope.pl = [];