Thank you very much, that works perfectly.
I managed to solve the problem.
I changed the updateChart function as according to this forum post https://canvasjs.com/forums/topic/how-to-update-chart-data-every-second/
Thank you for the help.
If you get have color as “none” on the pie chart it will make everything invisible. Try deleting the ‘color: “none”,’ line that should show default colors.
@Samuel Hey,
You can use the legend to do what you are asking. Look at https://canvasjs.com/docs/charts/chart-options/legend/ for more info about it. Hopefully this helps.
I don’t know if its of any use to you but here is the code the code that gets my data for me
<?php $dataPoints = array(); try{ // Creating a new connection. $link = new \PDO( 'mysql:host=192.168.0.89;dbname=light;charset=utf8mb4', 'Jack', 'Password', array( \PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, \PDO::ATTR_PERSISTENT => false ) ); $handle = $link->prepare('select BTime, TSensor2 from bottomsensors'); $handle->execute(); $result = $handle->fetchAll(\PDO::FETCH_OBJ); foreach($result as $row){ array_push($dataPoints, array("x"=> strtotime($row->BTime)*1000, "y"=> $row->TSensor2)); } $link = null; } catch(\PDOException $ex){ print($ex->getMessage()); } echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
I’m not sure that would be possible as the JSON.php file I use to get my json data pulls it straight from a local hosted database. And the code I posted above updates data dynamically from the database.
I altered my code to match the jsfiddle you linked but now my graph will no longer update in real time.