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

[BUG] Updating ticks fontColor is not working #5105

Closed
uffou opened this issue Jan 3, 2018 · 4 comments
Closed

[BUG] Updating ticks fontColor is not working #5105

uffou opened this issue Jan 3, 2018 · 4 comments

Comments

@uffou
Copy link

uffou commented Jan 3, 2018

I am attempting to update scales ticks and grid lines to be visible only on hover. It works for the grid lines but it does not work for the ticks. Changing with display works but it is not suitable because it changes the width of the chart.
Interactive demo: https://codepen.io/uffou/pen/zpdZVb

Expected Behavior

image

Current Behavior

image

@simonbrunel
Copy link
Member

Looks like a bug, need investigation, we might cache some options that are not correctly updated.

@jcopperfield
Copy link
Contributor

@uffou I think this is the same problem as #4896
There isn't a real bugfix, however you could use myChart.options.scales.yAxes[0].ticks.minor.fontColor as a workaround.

ctx.addEventListener('mouseenter', function(){
  myChart.options.scales.yAxes[0].gridLines.color = `red`;
  myChart.options.scales.yAxes[0].ticks.minor.fontColor = `red`;
  myChart.update();
});
ctx.addEventListener('mouseleave', function(){
  myChart.options.scales.yAxes[0].gridLines.color = `rgba(0,0,0,0)`;
  myChart.options.scales.yAxes[0].ticks.minor.fontColor = `rgba(0,0,0,0)`;
  myChart.update();
});

@uffou
Copy link
Author

uffou commented Jan 5, 2018

@jcopperfield thanks! that works 🎉

@simonbrunel
Copy link
Member

Thanks @jcopperfield, closing as duplicated of #4896.

We should avoid modifying the user given options object to store minor/major values from the ticks.* ones, but instead work on the clone of the scale options. That should ensure that minor/major are recalculated at each update.

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