Chartjs-JSON data in Chart.js is splitting values

0👍

Your data and labels must be an array. So your code will be something like:

function drawchart(){
  var yaxisdata = [yaxischartdata];
  var labeldata = [xaxischartdata];
  var Data1 = {
  labels : labeldata,
  datasets : [{
    fillColor             : "rgba(151,187,205,0.2)",
    strokeColor           : "rgba(151,187,205,1)",
    pointColor            : "rgba(151,187,205,1)",
    pointStrokeColor      : "#fff",
    pointHighlightFill    : "#fff",
    pointHighlightStroke  : "rgba(151,187,205,1)",
    data                  : yaxisdata
    }]
  };
  var ctx = $("#myChart").get(0).getContext("2d");
  var myLineChart = new Chart(ctx).Line(Data1);
};

Docs: http://www.chartjs.org/docs/#line-chart

Fiddle: https://jsfiddle.net/vcarvalho/qs2cnky4/

Leave a comment