You must be logged in to post your query.
Home › Forums › Chart Support › viewportMaximum – limit to 100 most recent values
I use canvasJS to display a Spline chart of temperature/humidity logs pulled from a CSV file.
The CSV looks like this for example (timestamp,temp,humidity%:
These readings are taken every 1 minute, so as you can imagine the file has thousands of lines, however when viewing the graph i would like to auto zoom to the most recent 100 values with the ability to scroll back if need be.
I dont think viewportMaximum allows me to do this as my X values (timestamps) are not integers. Does viewportMaximum or anything else in canvasJS allow me to only display the 100 most recent entries with an option to scroll back if need be?
You can set the x-value as a date object instead of using labels.
To only display a certain number of recent dataPoints you can set the viewportMinimum according to the number of dataPoints you would like to view. Please find the code snippet for the same below.
chart.axisX.set("viewportMinimum", dps[dps.length - 1 - dpsInView].x)
Please check this JSFiddle for a working example.
You must be logged in to reply to this topic. Login/Register