-
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
index-y interaction mode + convert horizontal bar defaults to new mode #4458
Conversation
Some thoughts: instead of duplicating modes for both axes, maybe we should introduce a new interaction options to select the orientation (
Could also apply to nearest and index:
(though not sure |
@simonbrunel that would work. Axis x would do the current behaviour, axis 'y' would do the new behaviour. I don't know that 'xy' is needed but we could add it for completeness |
Looks good (unit tests are failing though). Do we want unit tests for this new options? |
I thought I fixed those tests. will check again |
13abff7
to
de1cc57
Compare
@simonbrunel i added some tests for |
test/specs/core.interaction.tests.js
Outdated
} | ||
describe ('intersect: false', function() { | ||
it ('axis: x gets correct items', function() { | ||
var chart = window.acquireChart({ |
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.
Since these tests use the same chart input, we could refactor it in beforeEach()
under the describe ('intersect: false'
...` block?
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.
good call. will update
test/specs/core.interaction.tests.js
Outdated
var node = chart.canvas; | ||
var rect = node.getBoundingClientRect(); | ||
|
||
var evt = { |
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.
Might be easier and more accurate to generate a Chart.js event instead (nativeEvent: null
)?
Tests look fine, I would maybe also add tests for cases where it's supposed to return no elements (I don't know it that makes sense). |
Updated per the comments. I cleaned up all the tests to use |
…ts instead of native events. Added more tests for axis modes
test/specs/core.interaction.tests.js
Outdated
var chart; | ||
|
||
beforeEach(function() { | ||
chart = window.acquireChart({ |
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.
I think it's a bit cleaner to use this.chart
instead of a global variable.
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.
Looks good (just a minor comment), I rebased the PR since it was failing because of Chrome 60.
Awesome! Updated per your comment 😄 |
chartjs#4458) index-y interaction mode + convert horizontal bar defaults to new mode
chartjs#4458) index-y interaction mode + convert horizontal bar defaults to new mode
This new mode resolves #3905 and works much better for a horizontal bar chart when
intersect: false