Skip to content
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

Clean up factor range and add factor method #14037

Merged
merged 15 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
remove axis offsets cruft
  • Loading branch information
bryevdv committed Aug 25, 2024
commit e6020b7e0154caaf58553973bed74aa1e900b43a
15 changes: 4 additions & 11 deletions bokehjs/src/lib/models/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,9 @@ export class AxisView extends GuideRendererView {

const [sxs, sys] = this.scoords(coords)
const [nx, ny] = this.normals
const [xoff, yoff] = this.offsets

const [nxin, nyin] = [nx * (xoff-tin), ny * (yoff-tin)]
const [nxout, nyout] = [nx * (xoff+tout), ny * (yoff+tout)]
const [nxin, nyin] = [nx * -tin, ny * -tin]
const [nxout, nyout] = [nx * tout, ny * tout]

visuals.set_value(ctx)

Expand All @@ -360,12 +359,11 @@ export class AxisView extends GuideRendererView {
}

const [sxs, sys] = this.scoords(coords)
const [xoff, yoff] = this.offsets

const [nx, ny] = this.normals

const nxd = nx*(xoff + standoff)
const nyd = ny*(yoff + standoff)
const nxd = nx*standoff
const nyd = ny*standoff

const {vertical_align, align} = this.panel.get_label_text_heuristics(orient)
const angle = this.panel.get_label_angle_heuristic(orient)
Expand Down Expand Up @@ -557,11 +555,6 @@ export class AxisView extends GuideRendererView {
}
}

// TODO Remove this.
get offsets(): [number, number] {
return [0, 0]
}

get ranges(): [Range, Range] {
const i = this.dimension
const j = 1 - i
Expand Down
37 changes: 0 additions & 37 deletions bokehjs/test/unit/models/axes/axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,43 +118,6 @@ describe("Axis", () => {
expect(axis_view.loc).to.be.equal(10)
})

it("should return zero offsets when fixed_location is numeric", async () => {
const plot = new Plot({
x_range: new Range1d({start: 0, end: 10}),
y_range: new Range1d({start: 0, end: 10}),
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
ticker,
formatter,
fixed_location: 5,
})
plot.add_layout(axis, "left")
const {view: plot_view} = await display(plot)
const axis_view = plot_view.owner.get_one(axis)
expect(axis_view.offsets).to.be.equal([0, 0])
})

it("should return zero offsets when fixed_location is categorical", async () => {
const plot = new Plot({
x_range: new FactorRange({factors: ["foo", "bar"]}),
x_scale: new CategoricalScale(),
y_range: new Range1d({start: 0, end: 10}),
})
const ticker = new BasicTicker()
const formatter = new BasicTickFormatter()
const axis = new Axis({
ticker,
formatter,
fixed_location: "foo",
})
plot.add_layout(axis, "left")
const {view: plot_view} = await display(plot)
const axis_view = plot_view.owner.get_one(axis)
expect(axis_view.offsets).to.be.equal([0, 0])
})

it("loc should return synthetic for categorical fixed_location", async () => {
const plot = new Plot({
x_range: new FactorRange({factors: ["foo", "bar"]}),
Expand Down
Loading