Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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.

Post History

50%
+0 −0
Q&A 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 doc...

1 answer  ·  posted 1y ago by CavanWright‭  ·  last activity 1y ago by Ullallulloo‭

Question chart.js
#1: Initial revision by user avatar CavanWright‭ · 2023-10-12T15:09:35Z (about 1 year ago)
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](https://www.chartjs.org/docs/latest/axes/cartesian/), there don't seem to be any options for accessing them.

[These](https://stackoverflow.com/questions/58644695/chart-js-how-to-get-min-max-values-of-x-axis) [two](https://stackoverflow.com/questions/58352678/chartjs-finding-the-minimum-and-maximum-labels-that-are-inside-a-pan-when-zoo) 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?