In the jsfiddle that you have shared y-values passed to the dataPoints are string. Y-values in dataPoints can accept numeric values only. Changing it to numeric should work fine in your case. Please take a look at this updated jsfiddle.
—
Vishwas R
Team CanvasJS
You can render chart inside a table row/cell. Please take a look at this jsfiddle.
—
Vishwas R
Team CanvasJS
Shift is a JavaScript array method that removes the first item of an array. Please refer this link for more info on the same. Please refer our documentation for complete step-by-step tutorial on creating dynamic charts.
—
Vishwas R
Team CanvasJS
Legends will be shown for every dataSeries. You can enable legend by setting showInLegend property in dataSeries level to true. Text shown in legend can be set with the help of name or legendText.
—
Vishwas R
Team CanvasJS
You seemed to be using chart within getData method but which is undefined as its not passed when the function is called. Passing chart as parameter to getData method should work fine in your case getData(chart);
.
It would be helpful for us to understand your scenario better when we look at your code working live in jsfiddle. So I kindly request you to create jsfiddle and share it with us if you find any issue working in CanvasJS in future.
—
Vishwas R
Team CanvasJS
valueFormatString is used to format numbers and date time values (x-values) that appears on axisX but not for labels. Passing x-value to dataPoints should work fine in your case dps.push({"x":new Date(result[i].time), "y":result[i].humidity});
.
To format labels, you can use labelFormatter.
—
Vishwas R
Team CanvasJS
Please take a look at an gallery example on Chart Data from Database for rendering chart in PHP with data from mysql database. You can also download PHP Samples from our download page for more working examples in PHP.
—
Vishwas R
Team CanvasJS
Can you kindly share sample project along with sample database over Google-Drive or Onedrive so that we can look at your code, understand it better and help you out?
—
Vishwas R
Team CanvasJS
X-Value can be numeric or date-time. But in the dataPoints that you are passing x-values are string. Changing ‘x’ to label, i.e. [{"y":1,"label":"model3"},{"y":1,"label":"model4″},{"y":1,"label":"model1"},{"y":1,"label":"model2"}]
should work fine.
—
Vishwas R
Team CanvasJS
$ / jQuery is not defined
is caused when jQuery is not loaded in the web-page. Including jQuery should work fine in your case.
If this doesn’t solve the issue you are facing, kindly create a static HTML file reproducing the issue you are facing and share it over Google-Drive or Onedrive so that we can look into your code and help you out.
—
Vishwas R
Team CanvasJS