Thanks to visit codestin.com
Credit goes to github.com

Skip to content

line chart: skip axis label render based on visibility#5317

Merged
stephanwlee merged 3 commits into
tensorflow:masterfrom
stephanwlee:axis_render
Sep 17, 2021
Merged

line chart: skip axis label render based on visibility#5317
stephanwlee merged 3 commits into
tensorflow:masterfrom
stephanwlee:axis_render

Conversation

@stephanwlee
Copy link
Copy Markdown
Contributor

@stephanwlee stephanwlee commented Sep 17, 2021

This change improves line chart axis by measuring how big the label is
so a label does not overlap with another.

Instead of using DOM to measure the dimension, this uses 2D Canvas to
measure the text which is a lot performant as it would not have to cause
reflow.

Do note that we can be smarter with the tick filtering but this
iteration is quite dumb and only filters from the start.

Screenshot from 2021-09-16 17-34-21

This change improves line chart axis by measuring how big the label is
so a label does not overlap with another.

Instead of using DOM to measure the dimension, this uses 2D Canvas to
measure the text which is a lot performant as it would not have to cause
reflow.

Do note that we can be smarter with the tick filtering but this
iteration is quite dumb and only filters from the start.

const canvasForMeasure = document.createElement('canvas').getContext('2d');

export function filterTicksByVisibility(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add docstring to explain this function along with the parameters?
I do not fully understand them until read the tests. (especially getDomPos and marginBetweenAxis)

Comment thread tensorboard/webapp/widgets/line_chart_v2/sub_view/line_chart_axis_view.ts Outdated
@stephanwlee stephanwlee merged commit a060de9 into tensorflow:master Sep 17, 2021
@stephanwlee stephanwlee deleted the axis_render branch September 17, 2021 22:24
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
This change improves line chart axis by measuring how big the label is
so a label does not overlap with another.

Instead of using DOM to measure the dimension, this uses 2D Canvas to
measure the text which is a lot performant as it would not have to cause
reflow.

Do note that we can be smarter with the tick filtering but this
iteration is quite dumb and only filters from the start.
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
This change improves line chart axis by measuring how big the label is
so a label does not overlap with another.

Instead of using DOM to measure the dimension, this uses 2D Canvas to
measure the text which is a lot performant as it would not have to cause
reflow.

Do note that we can be smarter with the tick filtering but this
iteration is quite dumb and only filters from the start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants