KEMBAR78
line chart: skip axis label render based on visibility by stephanwlee · Pull Request #5317 · tensorflow/tensorboard · GitHub
Skip to content

Conversation

@stephanwlee
Copy link
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
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)

@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