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

Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
rest to old tick behavior
  • Loading branch information
mosc9575 committed Feb 15, 2025
commit 011cf12cc47fd309fc09d68061229cd1f83c4c1b
44 changes: 0 additions & 44 deletions bokehjs/src/lib/models/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,50 +420,6 @@ export abstract class AxisView extends GuideRendererView {
const {major_label_policy} = this.model
const selected = major_label_policy.filter(indices, bboxes, dist)

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).

for (const i of selected) {
const label = items[i]
label.paint(ctx)
Expand Down
Loading