You must be logged in to post your query.
Home › Forums › Chart Support › xValueType
Hi, i have a date format like this 2019-01-26 07:25:01 as source and i want to use it in my canvasjs. I use mysql too so i can’t really change it. Here is my skript if can help:
2019-01-26 07:25:01
<script> window.onload = function () { var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, title:{ text: "Utilizzo RAM" }, axisY: { title: "Utilizzo RAM in MB", valueFormatString: "#0,,.", suffix: "MB", prefix: "" }, data: [{ type: "spline", markerSize: 5, xValueFormatString: "YYYY-MM-DD HH:mm:ss", yValueFormatString: "####MB", xValueType: "dataTime", dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?> }] }); chart.render(); } </script>
But, when i put it in my page, in the console i get this error:
canvasjs.min.js:209 Uncaught TypeError: Cannot read property 'getTime' of null at l._processMultiseriesPlotUnit (canvasjs.min.js:209) at l._processData (canvasjs.min.js:206) at l.setLayout (canvasjs.min.js:189) at l.render (canvasjs.min.js:201) at window.onload (status.php:30) l._processMultiseriesPlotUnit @ canvasjs.min.js:209 l._processData @ canvasjs.min.js:206 l.setLayout @ canvasjs.min.js:189 l.render @ canvasjs.min.js:201 window.onload @ status.php:30 load (async) (anonymous) @ status.php:8
Then, i can see only a white space where there should be the canvas, but empty. Somebody can help me? Thanks advice!
@gabryca,
There is a typo in your code xValueType: "dataTime",. Please change dataTime to dateTime and it should work fine. You can also refer to this documentation page for more information.
xValueType: "dataTime",
In case it doesn’t help you out, can you please create a sample project with a sample database and share it over Google-Drive or Onedrive so that we can look into your code understand it better and help you out?
___________ Indranil Deo, Team CanvasJS
Fixed by using this https://ljvmiranda921.github.io/notebook/2017/02/21/make-canvasjs-chart-from-mysql-data/
Glad that you figured out a way to make it work :)
You must be logged in to reply to this topic. Login/Register