-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Use element options for removeHoverStyle(), even when inheriting #5194
Closed
Closed
Changes from 12 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c98185e
Refactor updateElement and removeHoverStyle
loicbourgois 8de5a31
Update style only
loicbourgois 87929a4
typo
loicbourgois 0bf1910
Refactor
loicbourgois 8f664f1
Revert "Refactor"
loicbourgois bb2c547
Revert "typo"
loicbourgois 9388dd8
Revert "Update style only"
loicbourgois ac18953
Revert "Refactor updateElement and removeHoverStyle"
loicbourgois 0f96799
Merge branch 'master' of https://github.com/chartjs/Chart.js into bor…
loicbourgois a9af225
Implement @simonbrunel solution
loicbourgois dc2a66e
Mix @simbrunel solution with previous implementation
loicbourgois af1abd2
Update failing test
loicbourgois 2527620
Remove not.toBe()
loicbourgois b8c5aef
Merge branch 'master' of https://github.com/chartjs/Chart.js into bor…
loicbourgois 4b30773
Refactor
loicbourgois c8064d6
Better hover style for line
loicbourgois fcef4b6
Update radar hover style logic
loicbourgois fad0561
cleanup
loicbourgois 743a123
refactor
loicbourgois 57f3df0
refactor
loicbourgois 07bf637
refactor
loicbourgois 7448c51
refactor
loicbourgois 0d9a74b
Pass tests
loicbourgois d89c572
Refactor
loicbourgois 2d9a387
refactor
loicbourgois ea376e6
setup test
loicbourgois 693fb03
Comment seamingly unecessary code
loicbourgois 92cb840
Setup test for doughnut.controller.removeHoverStyle()
loicbourgois 9cd0686
Test commenting seamingly unnecessary code
loicbourgois File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1372,13 +1372,23 @@ describe('Chart.controllers.bar', function() { | |
|
||
var meta = chart.getDatasetMeta(1); | ||
var bar = meta.data[0]; | ||
var helpers = window.Chart.helpers; | ||
|
||
// Change default | ||
chart.options.elements.rectangle.backgroundColor = 'rgb(128, 128, 128)'; | ||
chart.options.elements.rectangle.borderColor = 'rgb(15, 15, 15)'; | ||
chart.options.elements.rectangle.borderWidth = 3.14; | ||
|
||
// Remove to defaults | ||
chart.update(); | ||
expect(bar._model.backgroundColor).toBe('rgb(128, 128, 128)'); | ||
expect(bar._model.borderColor).toBe('rgb(15, 15, 15)'); | ||
expect(bar._model.borderWidth).toBe(3.14); | ||
meta.controller.setHoverStyle(bar); | ||
expect(bar._model.backgroundColor).not.toBe('rgb(128, 128, 128)'); | ||
expect(bar._model.borderColor).not.toBe('rgb(15, 15, 15)'); | ||
expect(bar._model.backgroundColor).toBe(helpers.getHoverColor('rgb(128, 128, 128)')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure which one is better :
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say |
||
expect(bar._model.borderColor).toBe(helpers.getHoverColor('rgb(15, 15, 15)')); | ||
expect(bar._model.borderWidth).toBe(3.14); | ||
meta.controller.removeHoverStyle(bar); | ||
expect(bar._model.backgroundColor).toBe('rgb(128, 128, 128)'); | ||
expect(bar._model.borderColor).toBe('rgb(15, 15, 15)'); | ||
|
@@ -1389,6 +1399,16 @@ describe('Chart.controllers.bar', function() { | |
chart.data.datasets[1].borderColor = ['rgb(9, 9, 9)', 'rgb(0, 0, 0)']; | ||
chart.data.datasets[1].borderWidth = [2.5, 5]; | ||
|
||
chart.update(); | ||
expect(bar._model.backgroundColor).toBe('rgb(255, 255, 255)'); | ||
expect(bar._model.borderColor).toBe('rgb(9, 9, 9)'); | ||
expect(bar._model.borderWidth).toBe(2.5); | ||
meta.controller.setHoverStyle(bar); | ||
expect(bar._model.backgroundColor).not.toBe('rgb(255, 255, 255)'); | ||
expect(bar._model.borderColor).not.toBe('rgb(9, 9, 9)'); | ||
expect(bar._model.backgroundColor).toBe(helpers.getHoverColor('rgb(255, 255, 255)')); | ||
expect(bar._model.borderColor).toBe(helpers.getHoverColor('rgb(9, 9, 9)')); | ||
expect(bar._model.borderWidth).toBe(2.5); | ||
meta.controller.removeHoverStyle(bar); | ||
expect(bar._model.backgroundColor).toBe('rgb(255, 255, 255)'); | ||
expect(bar._model.borderColor).toBe('rgb(9, 9, 9)'); | ||
|
@@ -1401,6 +1421,16 @@ describe('Chart.controllers.bar', function() { | |
borderWidth: 1.5 | ||
}; | ||
|
||
chart.update(); | ||
expect(bar._model.backgroundColor).toBe('rgb(255, 0, 0)'); | ||
expect(bar._model.borderColor).toBe('rgb(0, 255, 0)'); | ||
expect(bar._model.borderWidth).toBe(1.5); | ||
meta.controller.setHoverStyle(bar); | ||
expect(bar._model.backgroundColor).not.toBe('rgb(255, 0, 0)'); | ||
expect(bar._model.borderColor).not.toBe('rgb(0, 255, 0)'); | ||
expect(bar._model.backgroundColor).toBe(helpers.getHoverColor('rgb(255, 0, 0)')); | ||
expect(bar._model.borderColor).toBe(helpers.getHoverColor('rgb(0, 255, 0)')); | ||
expect(bar._model.borderWidth).toBe(1.5); | ||
meta.controller.removeHoverStyle(bar); | ||
expect(bar._model.backgroundColor).toBe('rgb(255, 0, 0)'); | ||
expect(bar._model.borderColor).toBe('rgb(0, 255, 0)'); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line also seems like it would be unnecessary. It doesn't hurt to leave it I suppose, but I'm not sure it ever has any effect