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: enable or disable ruler #765

Merged
merged 11 commits into from
Sep 15, 2020

Conversation

JennChao
Copy link
Contributor

Updates

User can enable or disable chart ruler.
Another PR or fixing tooltip not showing up when ruler is not applied has already been created. #764

Demo screenshot or recording

圖片

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)

@JennChao JennChao requested review from natashadecoste, theiliad and a team as code owners August 26, 2020 07:18
@JennChao JennChao requested review from Donisius and removed request for a team August 26, 2020 07:18
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.

wouldn't this PR need to also add some code in ruler to disable itself if it's been configured to be disabled?

Also @jeanservaas do we want to allow disabling the ruler?

@JennChao
Copy link
Contributor Author

JennChao commented Aug 27, 2020

wouldn't this PR need to also add some code in ruler to disable itself if it's been configured to be disabled?

Also @jeanservaas do we want to allow disabling the ruler?

@theiliad
By saying disable ruler itself, do you mean not pushing Ruler component into graphFrameComponents array?
圖片

I actually suggest just have the following code in Ruler component. Then we don't need to have duplicated code for modifying all the chart components.
圖片

And I think we should allowed the user to configures for disabling the ruler when needed. Here is one example of not ruler in the chart. In this example, all we need is a simple sparkline.
圖片

@JennChao JennChao requested a review from theiliad August 27, 2020 02:26
@@ -24,10 +24,17 @@ export class Ruler extends Component {
domainValue: number;
originalData: any;
}[];
isRulerEnabled = Tools.getProperty(
Copy link
Member

Choose a reason for hiding this comment

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

this should go inside render, that way it's value will update with future renders


render() {
this.drawBackdrop();
this.addBackdropEventListeners();
if (this.isRulerEnabled) {
Copy link
Member

Choose a reason for hiding this comment

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

what if ruler was enabled and now isn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

backdrop event listener will be remove first and then be created is if needed

this.model.getOptions(),
"ruler",
"enabled"
);

render() {
this.drawBackdrop();
Copy link
Member

Choose a reason for hiding this comment

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

it seems like drawBackdrop is repeated in ruler & grid. Would ruler fully function without it?

Copy link
Contributor Author

@JennChao JennChao Aug 28, 2020

Choose a reason for hiding this comment

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

ruler needs backdrop since the event listener is applied on backdrop.
圖片

Copy link
Member

Choose a reason for hiding this comment

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

I get that ruler is dependant on backdrop, however I'm wondering if these lines are needed inside ruler.ts

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I am not sure about it. These lines of code have existed even before I added the ruler option.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I'm just asking whether removing them on your end still makes everything work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As what I can see do far, removing code within line 253 to line 261 won't break any thing on my end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Codes within line 253 to line 261 have already been removed.

@JennChao JennChao requested a review from theiliad August 28, 2020 09:07
this.model.getOptions(),
"ruler",
"enabled"
);

render() {
this.drawBackdrop();
Copy link
Member

Choose a reason for hiding this comment

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

I get that ruler is dependant on backdrop, however I'm wondering if these lines are needed inside ruler.ts

image

@JennChao JennChao requested a review from theiliad September 1, 2020 09:26
this.model.getOptions(),
"ruler",
"enabled"
);

render() {
this.drawBackdrop();
Copy link
Member

Choose a reason for hiding this comment

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

Yes I'm just asking whether removing them on your end still makes everything work?


if (isRulerEnabled) {
this.addBackdropEventListeners();
}
Copy link
Member

Choose a reason for hiding this comment

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

so we remove & add event listeners every time? This doesn't sound healthy, there should be a better way to only remove or add when we need to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since d3 doesn't have an api for checking whether a specific eventListener is already existed or not. Removing and then adding event listeners when needed is what we can do for now.

Copy link
Member

Choose a reason for hiding this comment

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

again this is the same situation as the other PR, we just need a boolean here to keep track of event listeners

Copy link
Contributor Author

@JennChao JennChao Sep 11, 2020

Choose a reason for hiding this comment

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

A flag, isEventListenerAdded, has been added.

@JennChao JennChao requested a review from theiliad September 2, 2020 08:38

if (isRulerEnabled) {
this.addBackdropEventListeners();
}
Copy link
Member

Choose a reason for hiding this comment

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

again this is the same situation as the other PR, we just need a boolean here to keep track of event listeners

…to ruler-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.36.4
  Merge pull request carbon-design-system#761 from JennChao/sparkline
  Merge pull request carbon-design-system#793 from hlyang397/update-initial-zoom-domain
  fix the defect of label tooltip not showing when using custom tooltip (carbon-design-system#787)
  v0.36.3
  Merge pull request carbon-design-system#785 from sophiiae/skeleton-with-data
@JennChao JennChao requested a review from theiliad September 11, 2020 03:35
this.isEventListenerAdded = true;
this.addBackdropEventListeners();
} else if (!isRulerEnabled && this.isEventListenerAdded) {
this.isEventListenerAdded = false;
Copy link
Member

Choose a reason for hiding this comment

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

this line should be inside removeBackdropEventListeners()

this.addBackdropEventListeners();

if (isRulerEnabled && !this.isEventListenerAdded) {
this.isEventListenerAdded = true;
Copy link
Member

Choose a reason for hiding this comment

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

this line should be inside addBackdropEventListeners()

…to ruler-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.37.1
  Merge pull request carbon-design-system#800 from metonym/fix-svelte-base-chart
  v0.37.0
  Merge pull request carbon-design-system#780 from natashadecoste/fix-meter-max-val
  feat: enable or disable scatter dot on charts except scatter chart (carbon-design-system#769)
  feat: create options for tick rotation (carbon-design-system#770)
@JennChao JennChao requested a review from theiliad September 15, 2020 07:36
@theiliad theiliad merged commit bef6daf into carbon-design-system:master Sep 15, 2020
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 16, 2020
…to linearGradient

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.38.0
  Update README.md
  Update README.md
  Update README.md
  Update README.md
  Update vue.ts
  Update angular.ts
  Update react.ts
  Update vanilla.ts
  Update README.md
  Merge pull request carbon-design-system#780 from JennChao/axis-option
  feat(core): enable or disable ruler (carbon-design-system#765)
  v0.37.1
  Merge pull request carbon-design-system#800 from metonym/fix-svelte-base-chart
JennChao added a commit to JennChao/carbon-charts that referenced this pull request Sep 16, 2020
…to tooltip-option

* 'master' of https://github.com/JennChao/carbon-charts:
  v0.38.0
  Update README.md
  Update README.md
  Update README.md
  Update README.md
  Update vue.ts
  Update angular.ts
  Update react.ts
  Update vanilla.ts
  Update README.md
  Merge pull request carbon-design-system#780 from JennChao/axis-option
  feat(core): enable or disable ruler (carbon-design-system#765)
theiliad pushed a commit to theiliad/carbon-charts that referenced this pull request May 17, 2021
* feat: enable or disable ruler

* fix: enable ruler as default setting

* refactor: move isRulerEnabled into render

* refactor: remove backdrop event listener

* refactor: remove code for styling backdrop in ruler component

* refactor: flag for checking event listener added status

* refactor: refactor ruler component
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.

4 participants