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] Border disappears after hover on candlestick #24

Closed
loicbourgois opened this issue Jan 26, 2018 · 7 comments
Closed

[BUG] Border disappears after hover on candlestick #24

loicbourgois opened this issue Jan 26, 2018 · 7 comments

Comments

@loicbourgois
Copy link
Contributor

On a candlestick chart, after hovering over a value, the borders disappear if the chart is configured to display a tooltip with the following parameters :

options: {
  tooltips: {
    position: 'nearest',
    mode: 'index',
  },
},

jsfiddle

Before hover

image

After

image

@loicbourgois loicbourgois changed the title [BUG] Border disappear after hover on candlestick [BUG] Border disappears after hover on candlestick Jan 26, 2018
@benmccann
Copy link
Collaborator

@loicbourgois thanks for reporting. This didn't use to happen before your commit to add OHLC support. You can verify by going back to the commit before that with git reset --hard bc161d0ed61f92dc72d90684ba77ca6b3e91e09e. Would you be able to look into this issue?

@loicbourgois
Copy link
Contributor Author

Yes, I'm on it.

And actually, I think the problem has to do with the borderColor option in datasets.

See updated jsfiddle.

@loicbourgois
Copy link
Contributor Author

I added console.log(vm.borderColor, globalOpts.elements.candlestick.borderColor); in Chart.elements.Candlestick.draw().
Used this code in a new jsfiddle

If borderColor is set, I have the following behavior for console.log() :

  • before hover : #000 rgba(90, 90, 90, 1)
  • during hover : rgb(0, 0, 0) rgba(90, 90, 90, 1)
  • after hover : #000 rgba(90, 90, 90, 1)

If borderColor is undefined, I have the following behavior for console.log() :

  • before hover : undefined "rgba(90, 90, 90, 1)"
  • during hover : rgba(0, 0, 0, 0.1) rgba(90, 90, 90, 1)
  • after hover : rgba(0,0,0,0.1) rgba(90, 90, 90, 1)

Also, I ran some grep commands :

$ grep -rnw ~/chartjs-chart-financial/src/ -e 'rgba(0, 0, 0, 0.1)'
no result
$ grep -rnw ~/chartjs-chart-financial/src/ -e 'rgba(0,0,0,0.1)'
no result
$ grep -rnw ~/Chart.js/src/ -e 'rgba(0, 0, 0, 0.1)'
~/Chart.js/src/scales/scale.radialLinear.js:20:			color: 'rgba(0, 0, 0, 0.1)',
~/Chart.js/src/core/core.scale.js:16:		color: 'rgba(0, 0, 0, 0.1)',
$ grep -rnw ~/Chart.js/src/ -e 'rgba(0,0,0,0.1)'
~/Chart.js/src/core/core.js:17:	defaultColor: 'rgba(0,0,0,0.1)',

So from what I understand, there is some code in a function related to hovering in Chart.js that checks if vm.borderColor is defined, and if it's not the case it affects a default value.

@benmccann Is this a bug in Chart.js or should this be resolved in financial ?

Also, I find it strange that while hovering, the value is changed from #000 to rgb(0, 0, 0)
Finally, there is some inconsistency with the colors : rgba(0, 0, 0, 0.1) vs rgba(0,0,0,0.1). Does this justify a pull request ?

@benmccann
Copy link
Collaborator

This sounds like a bug in Chart.js. I'd recommend seeing if you can reproduce it with a plain bar chart or scatter chart to verify that and filing an issue upstream at https://github.com/chartjs/Chart.js/issues

@loicbourgois
Copy link
Contributor Author

Found a way to fix the issue in Chart.js loicbourgois/Chart.js@ea150cd (but if feels like a hack)
jsfiddle
Will submit a PR in Chart.js

@benmccann
Copy link
Collaborator

This will be fixed in the next release of Chart.js chartjs/Chart.js#5570

Thanks @loicbourgois for discovering the issue and driving the fix!

@benmccann
Copy link
Collaborator

This is fixed now. Thanks @loicbourgois for the report and all the help towards getting it fixed

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

No branches or pull requests

2 participants