-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
update text inside donut based on highlighted arc #33301
update text inside donut based on highlighted arc #33301
Conversation
Pull request demo site: URL |
const lineHeight = this._textInsideDonut.getBoundingClientRect().height; | ||
wrapText(this._textInsideDonut, 2 * this.innerRadius); | ||
const lines = this._textInsideDonut.getElementsByTagName('tspan'); | ||
const start = -Math.trunc((lines.length - 1) / 2); |
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.
is this a minus sign?
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
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 is error prone. Make it -1*Math.trunc
const start = -Math.trunc((lines.length - 1) / 2); | ||
for (let i = 0; i < lines.length; i++) { | ||
lines[i].setAttribute('dy', `${(start + i) * lineHeight}`); | ||
this._textInsideDonut = document.createElementNS(SVG_NAMESPACE_URI, 'text'); |
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.
can we make this part of the template?
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.
@krkshitij can u answer this.
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, it can be done. But then all arc paths should be inserted before this text to ensure that the text appears on top when it overflows.
Make sure the build, test lint steps are passing by running |
Previous Behavior
New Behavior
Related Issue(s)