Skip to content

Commit

Permalink
Fix PatchesView._mask_data() for secondary ranges (bokeh#14016)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap authored Aug 9, 2024
1 parent 61b87ac commit 5aecc61
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bokehjs/src/lib/models/glyphs/multi_polygons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export class MultiPolygonsView extends GlyphView {
}

protected override _mask_data(): Indices {
const {x_range, y_range} = this.renderer.plot_view.frame
const {x_source, y_source} = this.renderer.coordinates
return this.index.indices({
x0: x_range.min, x1: x_range.max,
y0: y_range.min, y1: y_range.max,
x0: x_source.min, x1: x_source.max,
y0: y_source.min, y1: y_source.max,
})
}

Expand Down
6 changes: 3 additions & 3 deletions bokehjs/src/lib/models/glyphs/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export class PatchesView extends GlyphView {
}

protected override _mask_data(): Indices {
const {x_range, y_range} = this.renderer.plot_view.frame
const {x_source, y_source} = this.renderer.coordinates
return this.index.indices({
x0: x_range.min, x1: x_range.max,
y0: y_range.min, y1: y_range.max,
x0: x_source.min, x1: x_source.max,
y0: y_source.min, y1: y_source.max,
})
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Figure bbox=[0, 0, 300, 150]
Canvas bbox=[0, 0, 300, 150]
CartesianFrame bbox=[84, 5, 211, 123]
GlyphRenderer bbox=[105, 100, 169, 62]
MultiPolygons bbox=[105, 100, 169, 62]
LinearAxis bbox=[84, 128, 211, 22]
LinearAxis bbox=[45, 5, 39, 123]
LinearAxis bbox=[0, 5, 45, 123]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Figure bbox=[0, 0, 300, 150]
Canvas bbox=[0, 0, 300, 150]
CartesianFrame bbox=[84, 5, 211, 123]
GlyphRenderer bbox=[105, 100, 169, 62]
Patches bbox=[105, 100, 169, 62]
LinearAxis bbox=[84, 128, 211, 22]
LinearAxis bbox=[45, 5, 39, 123]
LinearAxis bbox=[0, 5, 45, 123]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions bokehjs/test/integration/regressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4084,4 +4084,42 @@ describe("Bug", () => {
}
})
})

describe("in issue #14013", () => {
async function test(fn: (p: Figure) => GlyphRenderer) {
const p = fig([300, 150])

p.x_range = new Range1d({start: 0, end: 1000})
p.y_range = new Range1d({start: -1000, end: 1000})

// Set the second Y axis range to be offset from the primary Y axis range
p.extra_y_ranges = {
y_range2: new Range1d({start: 250, end: -750}),
}

p.add_layout(new LinearAxis({y_range_name: "y_range2"}), "left")

const gr = fn(p)
gr.y_range_name = "y_range2"

const {view} = await display(p)

const [sx0, sx1] = view.frame.x_scale.r_compute(500, 500)
const [sy0, sy1] = view.frame.y_scale.r_compute(-500, 550)

await actions(view, {units: "screen"}).pan(xy(sx0, sy0), xy(sx1, sy1))
}

const coords = [[100, 0], [900, 0], [900, -500], [100, -500]]
const xs = coords.map(([x, _]) => x)
const ys = coords.map(([_, y]) => y)

it("doesn't allow to respect secondary ranges when masking data in Patches glyph", async () => {
await test((p) => p.patches([xs], [ys]))
})

it("doesn't allow to respect secondary ranges when masking data in MultiPolygons glyph", async () => {
await test((p) => p.multi_polygons([[[xs]]], [[[ys]]]))
})
})
})

0 comments on commit 5aecc61

Please sign in to comment.