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

Dynamically updating ticks.mirror not working since 2.6 #5129

Closed
dibsyjr1 opened this issue Jan 10, 2018 · 6 comments
Closed

Dynamically updating ticks.mirror not working since 2.6 #5129

dibsyjr1 opened this issue Jan 10, 2018 · 6 comments

Comments

@dibsyjr1
Copy link
Contributor

dibsyjr1 commented Jan 10, 2018

In my project i've had a piece of code that's called onResize of the chart to determine whether or not the ticks should be shown on the inside of the chart in order to preserve space on smaller screens. This was working absolutely fine and I hadn't noticed it was broken until just recently, but i've reverted back to Chart.js 2.6 in order to test whether or not it was a fault in Chart.js or in the code i've written and it seems to be 2.7 onwards that the bug occurs.

It seems that now when I try to dynamically set ticks.mirror Chart.js seems to hide my ticks altogether instead of mirroring them. This might be to do with draw area as well because when I don't hide the scale label, but set mirror to true, the labels just get overlapped with the scale label outside of the chart area.

I am only mirroring the y-axis, the x-axis ticks are getting hidden, which is working as expected.

Unmirrored:
chartjsticks2 6

Mirrored - Chart.js 2.6.0:
chartjsmirrorticks2 6

Mirrored - Chart.js 2.7.0/2.7.1 (affects both):
chartjsmirrorticks2 7 1

This only seems to be an issue when dynamically updating the property as well, as hardcoding it on chart creation seems to work fine.

@etimberg
Copy link
Member

@dibsyjr1 does the mirrored display issue only happen when dynamically updating? or does it happen when mirror: true is set at the start?

@etimberg
Copy link
Member

This may have been fixed in #4198

@dibsyjr1
Copy link
Contributor Author

dibsyjr1 commented Jan 18, 2018

@etimberg only when dynamically updating them. If you set it in the options prior to creating the chart it works fine.

Excellent, from the looks of it this should solve my problem.

Thanks

@simonbrunel
Copy link
Member

I think it's the same issue as #4896, #4883, etc. where the ticks options are duplicated in ticks.minor and ticks.major and never updated after.

@dibsyjr1
Copy link
Contributor Author

Ahhhh yes, that is the issue, when I update ticks.minor.mirror instead of ticks.mirror it works as expected.

Thanks @simonbrunel

@simonbrunel
Copy link
Member

Closing as duplicate of #4896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants