-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Enable selectable correction mode for long tick labels #14333
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
base: branch-3.9
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
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:
|
bokehjs/src/lib/models/axes/axis.ts
Outdated
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) | ||
} | ||
} | ||
|
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 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 I changed the code to give the user the option to anable/disable the correction of the first label. I know some tests are missing. I will try to add them soon. |
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.
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.