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

index-y interaction mode + convert horizontal bar defaults to new mode #4458

Merged
merged 5 commits into from Jul 28, 2017

Conversation

etimberg
Copy link
Member

@etimberg etimberg commented Jul 4, 2017

This new mode resolves #3905 and works much better for a horizontal bar chart when intersect: false

@etimberg etimberg added this to the Version 2.7 milestone Jul 4, 2017
@simonbrunel
Copy link
Member

Some thoughts: instead of duplicating modes for both axes, maybe we should introduce a new interaction options to select the orientation (axis: 'x|y|xy')?

  • mode: 'point', axis: 'xy' would be the current 'point' mode
  • mode: 'point', axis: 'x' would replace the current 'x' mode
  • mode: 'point', axis: 'y' would replace the current 'y' mode

Could also apply to nearest and index:

  • mode: 'index', axis: 'xy' would select items with same index horizontally and vertically
  • mode: 'index', axis: 'x' would select items with same index horizontally
  • mode: 'index', axis: 'y' would select items with same index vertically

(though not sure mode: 'index', axis: 'xy'` would be very useful)

@etimberg
Copy link
Member Author

etimberg commented Jul 4, 2017

@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

@simonbrunel
Copy link
Member

Looks good (unit tests are failing though). Do we want unit tests for this new options?

@etimberg
Copy link
Member Author

I thought I fixed those tests. will check again

@etimberg etimberg force-pushed the fix/3905 branch 2 times, most recently from 13abff7 to de1cc57 Compare July 26, 2017 22:13
@etimberg
Copy link
Member Author

@simonbrunel i added some tests for index mode. if you like the style, I can add similar tests for dataset mode and nearest mode

}
describe ('intersect: false', function() {
it ('axis: x gets correct items', function() {
var chart = window.acquireChart({
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. will update

var node = chart.canvas;
var rect = node.getBoundingClientRect();

var evt = {
Copy link
Member

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)?

@simonbrunel
Copy link
Member

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).

@etimberg
Copy link
Member Author

Updated per the comments. I cleaned up all the tests to use beforeEach where appropriate.

var chart;

beforeEach(function() {
chart = window.acquireChart({
Copy link
Member

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.

Copy link
Member

@simonbrunel simonbrunel left a 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.

@etimberg
Copy link
Member Author

Awesome! Updated per your comment 😄

@etimberg etimberg merged commit 326991c into master Jul 28, 2017
@simonbrunel simonbrunel deleted the fix/3905 branch July 29, 2017 06:01
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
chartjs#4458)

index-y interaction mode + convert horizontal bar defaults to new mode
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
chartjs#4458)

index-y interaction mode + convert horizontal bar defaults to new mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

What replaces y-axis with v 2.4 mode upgrades?
2 participants