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

x number of minor ticks per major tick #13338

Closed
awall opened this issue Apr 17, 2020 · 11 comments · Fixed by #18540
Closed

x number of minor ticks per major tick #13338

awall opened this issue Apr 17, 2020 · 11 comments · Fixed by #18540
Assignees
Labels
Type: Feature Request Used when a new feature is requested either directly or indirectly Type: Good for beginners

Comments

@awall
Copy link

awall commented Apr 17, 2020

Description of the feature

When minorTicks is set to "auto", we get 5 minor ticks per major tick. Ideally, I would like to set the major ticks using other properties, like tickPixelInterval or tickAmount, and set the minor ticks as "2 minor ticks per major tick", or any other arbitrary multiple. Why restrict it to exactly 5?

Add some property to set this value from 5 to any arbitrary integer.
Please make sure it works in logarithmic and date axes, too!

Library related to the feature

Highcharts

You can vote for the feature by adding thumbs-up reaction for this post.

@awall awall added the Type: Feature Request Used when a new feature is requested either directly or indirectly label Apr 17, 2020
@sebastianbochan
Copy link
Contributor

sebastianbochan commented Apr 20, 2020

Hi @awall,
Thank you for your suggestion. I think that it could be something like tickAmount, but minorTickAmount.

We could parametrize this line:

highcharts/js/parts/Axis.js

Lines 1484 to 1487 in f9dc90d

minorTickIntervalOption === 'auto' &&
this.tickInterval ?
this.tickInterval / 5 :
minorTickIntervalOption;

As a workaround, have you tried to use a minorTickInterval param?

@awall
Copy link
Author

awall commented Apr 22, 2020

Thanks @sebastianbochan. In my case, the minorTickInterval does not work, it doesn't support logarithmic or date axes correctly (I've logged separate bugs for these issues already).

@KacperMadej
Copy link
Contributor

It works for logarithmic (https://jsfiddle.net/BlackLabel/vem4q6yt/) but doesn't look good since the offset is critical. It works for datetime (https://jsfiddle.net/BlackLabel/vem4q6yt/1/) - the units are milliseconds.

@awall
Copy link
Author

awall commented Apr 23, 2020

@KacperMadej Logarithmic only works for very specific numbers, try changing that "0.1" to "0.5" and see what happens ;). I've logged this bug already as #13337

As for datetime, I'd really like to use the default behaviour for the major ticks, and then just "2 minor ticks per major tick". If I use tickInterval and minorTickInterval, I need to write an enormous amount of tricky code involving dates and the chart width... this code is already built-in to how highcharts determines the major ticks on a date axis, and it is very painful to have to reverse engineer and duplicate that code.

@pawelfus
Copy link
Contributor

pawelfus commented May 4, 2020

See plugin posted in #13336. Demo: https://jsfiddle.net/BlackLabel/oc70hqxm/

@stale
Copy link

stale bot commented Apr 18, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions!

@stale stale bot added the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Apr 18, 2022
@pawellysy
Copy link
Member

unstale

@stale stale bot removed the Status: Stale This issue hasn't had any activity for a while, and will be auto-closed if no further updates occur. label Apr 20, 2022
@ReillyBova
Copy link

Unstale — this is a pretty reasonable customization request. 5 minor ticks per major is very noisy / visually dense. Having the option to set the "auto" value would be much appreciated

@TorsteinHonsi
Copy link
Collaborator

Thank you for your input @ReillyBova , I think we can get this done. We will do some internal discussions about how.

@TorsteinHonsi
Copy link
Collaborator

After some internal discussion, we decided to add a new option minorTicksPerMajor, which will default to 5. The implementation appears to be quite simple, just replace the number 5 on this line:

this.tickInterval / 5 :

My preliminary tests show that this works on linear, logarithmic and datetime axes.

@ReillyBova
Copy link

Awesome! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Request Used when a new feature is requested either directly or indirectly Type: Good for beginners
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants