-
Notifications
You must be signed in to change notification settings - Fork 185
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
Conversation
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.
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 I actually suggest just have the following code in 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. |
@@ -24,10 +24,17 @@ export class Ruler extends Component { | |||
domainValue: number; | |||
originalData: any; | |||
}[]; | |||
isRulerEnabled = Tools.getProperty( |
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 should go inside render
, that way it's value will update with future renders
|
||
render() { | ||
this.drawBackdrop(); | ||
this.addBackdropEventListeners(); | ||
if (this.isRulerEnabled) { |
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.
what if ruler was enabled and now isn't?
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.
backdrop event listener will be remove first and then be created is if needed
this.model.getOptions(), | ||
"ruler", | ||
"enabled" | ||
); | ||
|
||
render() { | ||
this.drawBackdrop(); |
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.
it seems like drawBackdrop
is repeated in ruler & grid. Would ruler fully function without it?
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.
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.
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.
Actually, I am not sure about it. These lines of code have existed even before I added the ruler option.
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.
Yes I'm just asking whether removing them on your end still makes everything work?
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.
As what I can see do far, removing code within line 253 to line 261 won't break any thing on my end.
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.
Codes within line 253 to line 261 have already been removed.
this.model.getOptions(), | ||
"ruler", | ||
"enabled" | ||
); | ||
|
||
render() { | ||
this.drawBackdrop(); |
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.model.getOptions(), | ||
"ruler", | ||
"enabled" | ||
); | ||
|
||
render() { | ||
this.drawBackdrop(); |
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.
Yes I'm just asking whether removing them on your end still makes everything work?
|
||
if (isRulerEnabled) { | ||
this.addBackdropEventListeners(); | ||
} |
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.
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
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 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.
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.
again this is the same situation as the other PR, we just need a boolean here to keep track of event listeners
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.
A flag, isEventListenerAdded
, has been added.
|
||
if (isRulerEnabled) { | ||
this.addBackdropEventListeners(); | ||
} |
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.
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
8a82247
to
65a83e0
Compare
this.isEventListenerAdded = true; | ||
this.addBackdropEventListeners(); | ||
} else if (!isRulerEnabled && this.isEventListenerAdded) { | ||
this.isEventListenerAdded = false; |
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 should be inside removeBackdropEventListeners()
this.addBackdropEventListeners(); | ||
|
||
if (isRulerEnabled && !this.isEventListenerAdded) { | ||
this.isEventListenerAdded = true; |
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 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)
…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
…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)
* 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
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)