Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix choosing of formatting unit #4779

Merged
merged 2 commits into from Oct 9, 2017
Merged

Conversation

benmccann
Copy link
Contributor

@benmccann benmccann commented Sep 20, 2017

Without this change, determineUnit is broken when specifying source:'data' (and often with source:'labels' though typically less noticeably). determineUnit figures out how far apart to put the ticks when generating auto-ticks. This isn't necessarily the unit we want to use for formatting.

E.g. consider the image below with source:data. If you set source:'auto' then it will generate a tick for every month. The code was thus trying to format the ticks with month formatting. However, when we have source:'data' set we have more than just monthly ticks, so we should use the appropriate formatter.

The determineUnitForAutoTicks, determineStepSize, etc. methods will be able to be deleted in a future PR and replaced with a fixed ratio as discussed with @simonbrunel over Slack. I didn't want to do that as part of this change as they're separable tasks and it would make the change too large to easily test and review. We will need the determineUnitForFormatting in both cases.

You can see this fix by looking at samples/scales/time/financial.html

Before:

before

After:

after

@benmccann benmccann force-pushed the tick-format branch 2 times, most recently from 23b7b87 to 78b9248 Compare September 20, 2017 18:04
@benmccann benmccann changed the title Don't change minorFormat when determining label capacity Fix choosing of formatting unit Sep 20, 2017
src/scales/scale.time.js Outdated Show resolved Hide resolved
@etimberg etimberg merged commit d81afc8 into chartjs:master Oct 9, 2017
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
* Don't change minorFormat when determining label capacity

* Fix choosing of formatting unit
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
* Don't change minorFormat when determining label capacity

* Fix choosing of formatting unit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants