Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
How do I get the min/max axis values in Chart.js?
I'd like to get the minimum and maximum values of the axes on a Chart.js 4.4.0 plot. When the plot is created, these values must be calculated somewhere. However, reading through the Chart.js docs, there don't seem to be any options for accessing them.
These two Stack Overflow questions are similar, but they're specific to using the
chartjs-plugin-zoom plugin, which I'm not using. Furthermore, the approach employed by the answer involves finding minimum and maximum tick values, which is not what I want. For instance, a graph may have ticks at every integer, but the right boundary of the plot might naturally fall at, say, x=10.5. I want to find the actual boundary of the plot at 10.5, not the maximum tick at 10.
In Flot.js, this was done trivially as
xmin = plot.getAxes().xaxis.min; xmax = plot.getAxes().xaxis.max;
Is this possible to do in Chart.js, and how?