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

Skip to content

Conversation

mosc9575
Copy link
Contributor

This PR brings back old behavoir of tick labels. If they are to long to be displayed, they are cut of. In the latest implementation the position was corrected, so that the labels would be disaligned. For long tick labels this looks odd, for formatted time stamps it coudl be easily misinterpreted.

grafik

I want to mention that I think this is not perfect. A better solution would be to shorten the labels from the end of the string.

Copy link

codecov bot commented Feb 15, 2025

Codecov Report

Attention: Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (branch-3.8@0e0c5d8). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff              @@
##             branch-3.8   #14333   +/-   ##
=============================================
  Coverage              ?   93.22%           
=============================================
  Files                 ?      285           
  Lines                 ?    20146           
  Branches              ?        0           
=============================================
  Hits                  ?    18782           
  Misses                ?     1364           
  Partials              ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mosc9575 mosc9575 changed the title rest to old tick behavior reset to old tick behavior Feb 15, 2025
Comment on lines 423 to 466
const ids = [...selected.ones()]
if (ids.length != 0) {
const cbox = this.canvas.bbox

const correct_x = (k: number) => {
const bbox = bboxes[k]

if (bbox.left < 0) {
const offset = -bbox.left
const {position} = items[k]
items[k].position = {...position, sx: position.sx + offset}
} else if (bbox.right > cbox.width) {
const offset = bbox.right - cbox.width
const {position} = items[k]
items[k].position = {...position, sx: position.sx - offset}
}
}

const correct_y = (k: number) => {
const bbox = bboxes[k]

if (bbox.top < 0) {
const offset = -bbox.top
const {position} = items[k]
items[k].position = {...position, sy: position.sy + offset}
} else if (bbox.bottom > cbox.height) {
const offset = bbox.bottom - cbox.height
const {position} = items[k]
items[k].position = {...position, sy: position.sy - offset}
}
}

const i = ids[0]
const j = ids[ids.length - 1]

if (this.dimension == 0) {
correct_x(i)
correct_x(j)
} else {
correct_y(i)
correct_y(j)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This actually works quite well for parallel labels. I would disable this for other orientations and perhaps add a property to control the behavior (never, auto (default) and always).

@mattpap mattpap changed the base branch from branch-3.7 to branch-3.8 March 7, 2025 07:56
@mosc9575
Copy link
Contributor Author

mosc9575 commented Mar 22, 2025

@mattpap I changed the code to give the user the option to anable/disable the correction of the first label.

axis_label_correction_policy

I know some tests are missing. I will try to add them soon.

@mosc9575 mosc9575 changed the title reset to old tick behavior Enable selectable correction mode for long tick labels Mar 23, 2025
@mosc9575 mosc9575 requested a review from mattpap March 23, 2025 10:10
@mattpap mattpap changed the base branch from branch-3.8 to branch-3.9 August 29, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Long x axis labels misaligned on charts
2 participants