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

feat: provide option to refresh range axis label #766

Merged
merged 9 commits into from
Oct 8, 2020

Conversation

hlyang397
Copy link
Contributor

Sometimes data value varies from 10 to 100,000. When zoom bar is moving, the range axis (y-axis) label should be refreshed immediately to avoid extremely small graphs.

Updates

  • add refreshRangeAxisLabel option (default to false)
  • add filterDataForRangeAxisLabel() in zoom service to provide data in zoom domain

Demo screenshot or recording

Option disabled (default) :
disabled

Option enabled:
enabled

Review checklist (for reviewers only)

  • Demos all features
  • Documented/annotated
  • Matches UI/UX specs
  • Meets the code style guide
  • Accessible
  • Mobile first (responsive)
  • RTL support (bidirectional text)
  • Performant (limited bloat)

- add refreshRangeAxisLabel option (default to false)
- add filterDataForRangeAxisLabel() in zoom service to provide data in zoom domain
@hlyang397 hlyang397 requested review from natashadecoste, theiliad and a team as code owners August 26, 2020 08:00
@hlyang397 hlyang397 requested review from cal-smith and removed request for a team August 26, 2020 08:00
@@ -149,7 +149,8 @@ const axisChart: AxisChartOptions = Tools.merge({}, chart, {
zoomBar: {
top: {
enabled: false,
type: ZoomBarTypes.GRAPH_VIEW
type: ZoomBarTypes.GRAPH_VIEW,
refreshRangeAxisLabel: false
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this makes sense here. What if in top you set refreshRangeAxisLabel to true and in bottom you set it to false? Seems like this would be a zoomBar level config. And it should probably be called updateRangeAxis or realtimeRangeAxis

Copy link
Contributor Author

@hlyang397 hlyang397 Aug 27, 2020

Choose a reason for hiding this comment

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

@theiliad
Thanks for the prompt review.
I think your comment makes sense.
The option name is changed to updateRangeAxis and moved to ZoomBarsOptions in b9abd4c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@theiliad
One more thought, how about moving this configuration toAxisOptions ?

Copy link
Member

Choose a reason for hiding this comment

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

well that depends. It seems like this is only relevant when you have a zoombar, isn't that the case?

Copy link
Contributor Author

@hlyang397 hlyang397 Aug 28, 2020

Choose a reason for hiding this comment

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

Yes, so far this option is required only zoom bar is enabled.
However, putting all axis-related options in the same AxisOptions also makes sense to me.
It's up to you.
Please let me know where you like to set this option, thanks.

packages/core/src/services/scales-cartesian.ts Outdated Show resolved Hide resolved
packages/core/src/services/zoom.ts Outdated Show resolved Hide resolved
@hlyang397 hlyang397 requested a review from theiliad August 28, 2020 03:38
natashadecoste
natashadecoste previously approved these changes Sep 1, 2020
@theiliad
Copy link
Member

theiliad commented Sep 1, 2020

@hlyang397 how much have you tested this? what if you start with an initial zoom domain that has a smaller y-axis range and then you zoom-out all the way? Will you see the full range at all times?

@hlyang397
Copy link
Contributor Author

@hlyang397 how much have you tested this? what if you start with an initial zoom domain that has a smaller y-axis range and then you zoom-out all the way? Will you see the full range at all times?

The y-axis range will be updated whenever zoom domain is changing, so it doesn't matter whether the chart starts from a smaller or bigger range.
Please refer to the demo below.

y-axis-update

@theiliad
Copy link
Member

theiliad commented Sep 2, 2020

@hlyang397 how much have you tested this? what if you start with an initial zoom domain that has a smaller y-axis range and then you zoom-out all the way? Will you see the full range at all times?

The y-axis range will be updated whenever zoom domain is changing, so it doesn't matter whether the chart starts from a smaller or bigger range.
Please refer to the demo below.

y-axis-update

Yes I'm asking about the case when refreshRangeAxisLabel would be set to false. What would happen then?

@hlyang397
Copy link
Contributor Author

Yes I'm asking about the case when refreshRangeAxisLabel would be set to false. What would happen then?

@theiliad
Yes, when updateRangeAxis is set to false, you will see the full range at all times, no matter what initial zoom domain is.
updateRangeAxis is default to false, so all storybook demos should look same as before.

/**
* whether keep updating range axis in real time while zoom domain is changing
*/
updateRangeAxis?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

I've already commented on this before, not sure where my comment went (usually they disappear if you force-push over the branch and the lines that were commented on get removed).

This seems like it should just be flag under:

{
  axes: {
      "top|left|bottom|right": {
         update: boolean;
      }
  }
}

whether it needs to be called update or updateWhenZooming depends on whether this only applies to zooming or not

Copy link
Contributor Author

@hlyang397 hlyang397 Sep 11, 2020

Choose a reason for hiding this comment

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

I will change it to updateWhenZooming since the axis won't change when zoom bar is disabled.
Updated in a224ab3.

@hlyang397
Copy link
Contributor Author

@theiliad I don't think we have any force-push in this PR. In that case, we should be able to find the force-push record like this:

image

@theiliad
Copy link
Member

@theiliad I don't think we have any force-push in this PR. In that case, we should be able to find the force-push record like this:

image

yes, what I was saying about this is that if I comment on line X and that line has been removed in a force-pushed commit, then the comment seems to get deleted forever on Github.

@hlyang397
Copy link
Contributor Author

@theiliad So any other comment on this PR?

theiliad
theiliad previously approved these changes Sep 15, 2020
Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

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

A bit unhappy that this is really just focusing on the main y-axis and not also the main x-axis, however I can't stand in the way of your progress

@sophiiae
Copy link
Contributor

@hlyang397 please fix the conflicts

natashadecoste
natashadecoste previously approved these changes Sep 15, 2020
# Conflicts:
#	packages/core/src/interfaces/axis-scales.ts
@hlyang397 hlyang397 dismissed stale reviews from natashadecoste and theiliad via 180b0b5 September 16, 2020 04:10
@hlyang397
Copy link
Contributor Author

A bit unhappy that this is really just focusing on the main y-axis and not also the main x-axis, however I can't stand in the way of your progress

@theiliad We don't have vertical zoom bar yet, so I can't test this feature on main x-axis, and that's why I focus on main y-axis for now.

@hlyang397
Copy link
Contributor Author

@hlyang397 please fix the conflicts

@sophiiae Latest master branch merged. Thanks.

theiliad
theiliad previously approved these changes Sep 16, 2020
natashadecoste
natashadecoste previously approved these changes Sep 16, 2020
# Conflicts:
#	packages/core/src/services/zoom.ts
cal-smith
cal-smith previously approved these changes Sep 30, 2020
Copy link
Contributor

@cal-smith cal-smith left a comment

Choose a reason for hiding this comment

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

LGTM!

this.model.getOptions(),
"axes",
this.services.cartesianScales.getMainYAxisPosition(),
"updateWhenZooming"
Copy link
Member

Choose a reason for hiding this comment

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

I was just testing this and realized that updateWhenZooming is available for all axes, however it only takes effect for the main Y-axis. this means that I can set it to false for the main X-axis and it will do nothing

Copy link
Member

Choose a reason for hiding this comment

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

we should either just make it available for the range axis like before, or if we are allowing it to be used for all axis then it should achieve something when set to false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@theiliad The domain axis is always changing while zoom domain is changing, so no option is required.
This new option should only works for the range axis (main Y axis).
So I change it back to updateRangeAxis under zoomBar.

Updated in 2cd37ad.

Please let me know if this is not what you expected.

@hlyang397
Copy link
Contributor Author

@theiliad Not sure what happened to Travis CI, I can pass the test locally.
Could you help to rerun the build in Travis CI ? Thanks.

@theiliad theiliad merged commit 070f9e3 into carbon-design-system:master Oct 8, 2020
@theiliad theiliad deleted the scalable-y-value branch October 8, 2020 16:11
theiliad pushed a commit to theiliad/carbon-charts that referenced this pull request May 17, 2021
…m#766)

* feat: provide option to refresh range axis label

- add refreshRangeAxisLabel option (default to false)
- add filterDataForRangeAxisLabel() in zoom service to provide data in zoom domain

* refactor: move updateRangeAxis to zoomBarsOptions

* refactor: use configs object instead of boolean as parameter

* refactor: move updateWhenZooming option to be under axis option

* refactor: change updateWhenZooming option to zoomBar.updateRangeAxis
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.

5 participants