You must be logged in to post your query.
Home › Forums › Chart Support › MYSQL + CanvasJS Multiple Series Chart
Hello,
I’m facing problems to make a chart with the data I get from mysql. I’ve managed to make charts with my database structured this way : {label,y} Now, I want to make a multi-series chart with this kind of database : {id,label,y} where ‘id’ value is the ident of one serie.
Here is my code :
<script type="text/javascript"> $(document).ready(function () { var dataPoints1 = []; var dataPoints2 = []; var dataPoints3 = []; $.getJSON("data2.php", function (result) { for( var i = 0; i < result.length; i++) { var label2= result[i].label.split(" "); dataPoints1.push({ label: label2[0], y: result[i].y1, toolTipContent: label2[1]+' / '+result[i].y1}); dataPoints2.push({ label: label2[0], y: result[i].y2, toolTipContent: label2[1]+' / '+result[i].y2}); dataPoints3.push({ label: label2[0], y: result[i].y3, toolTipContent: label2[1]+' / '+result[i].y3}); } var chart1 = new CanvasJS.Chart("chart1", {title:{text: "..."}, exportEnabled : true, legend:{}, data: [ { showInLegend: true, name: "val", legendText:"...", type: "spline", dataPoints: dataPoints1 }, ] }); chart1.render(); chart1={}; var chart2 = new CanvasJS.Chart("chart2", {title:{text: "..."}, exportEnabled : true, legend:{}, data: [ { showInLegend: true, name: "val", legendText:"...", type: "spline", dataPoints: dataPoints2 }, ] }); chart2.render(); chart2={}; var chart3 = new CanvasJS.Chart("chart3", {title:{text: ""}, exportEnabled : true, legend:{}, data: [ { showInLegend: true, name: "val", legendText:"...", type: "spline", dataPoints: dataPoints3 }, ] }); chart3.render(); chart3={}; }); }); </script>
Hi,
Without knowing the JSON data its not possible to figure out the issue. Can you please post a sample JSON response?
You must be logged in to reply to this topic. Login/Register