-
Notifications
You must be signed in to change notification settings - Fork 0
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: avoid label collision #247
base: develop
Are you sure you want to change the base?
Conversation
@@ -70,6 +70,7 @@ export class HistogramParams { | |||
public ticksDateFormat: string = null; | |||
public xAxisPosition: Position = Position.bottom; | |||
public descriptionPosition: Position = Position.bottom; | |||
public overlapXTolerance = 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.
why 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.
could be more if needed, it apply a padding of 2 on left and right side, to detect the overlap before the label collide.
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.
Maybe it should be an input ?
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.
could be a good idea !
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 good Idea, we should add a new input for this overlap tolerance
src/histograms/AbstractHistogram.ts
Outdated
} | ||
} | ||
|
||
if(!this._xlabelMeanWidth) { |
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.
Why not recompute it each time ?
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 var helps me to know when i can put more label when the chart grow. So i cacl the mean size once, when all label are displayed.
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.
The virtual labels always has the maximum number of labels right ?
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
for (let i = 0; i < labels.size(); i++) { | ||
const next = i + 1; | ||
if(nodes[next]){ | ||
const c = this.getDimension(nodes[i]); |
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.
Do 'c' and 'n' stand for current and next ? if so, can you add a comment for those var names or rename the variable ?
const horizontalOffset = this.getHorizontalOffset(chartAxes); | ||
let sumWidth = 0; | ||
// create virtual nodes. Helps to get label's width. | ||
const virtualLabels = this.chartDimensions.svg.append('g'); |
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.
I think you can try to select the already existing labels.
Or you need to use one common method between the real label axis and the virtual one in order to avoid duplication
@@ -70,6 +70,7 @@ export class HistogramParams { | |||
public ticksDateFormat: string = null; | |||
public xAxisPosition: Position = Position.bottom; | |||
public descriptionPosition: Position = Position.bottom; | |||
public overlapXTolerance = 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.
Yes good Idea, we should add a new input for this overlap tolerance
LGTM ! |
Capture.video.du.03-02-2025.18.25.25.webm