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.

Comments on How do I get the min/max axis values in Chart.js?

Parent

How do I get the min/max axis values in Chart.js?

+0
−0

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?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+2
−0

The equivalent in Chart.js would be:

xmin = chart.scales.x.min;
xmax = chart.scales.x.max;

This can be found in the docs as an option common to all axes.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

Works for me (1 comment)
Works for me
CavanWright‭ wrote about 1 year ago

I have no idea how you extracted that answer from the link you posted, but it seems to work. Thank you.