Skip to content

Commit

Permalink
Replace LabelSet with Text glyph
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap committed Oct 11, 2023
1 parent 421aed9 commit f8557dc
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 567 deletions.
1 change: 0 additions & 1 deletion bokehjs/src/lib/models/annotations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export {BoxAnnotation} from "./box_annotation"
export {ColorBar} from "./color_bar"
export {ContourColorBar} from "./contour_color_bar"
export {Label} from "./label"
export {LabelSet} from "./label_set"
export {Legend} from "./legend"
export {LegendItem} from "./legend_item"
export {PolyAnnotation} from "./poly_annotation"
Expand Down
155 changes: 0 additions & 155 deletions bokehjs/src/lib/models/annotations/label_set.ts

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
65 changes: 0 additions & 65 deletions bokehjs/test/integration/annotations/label_set.ts

This file was deleted.

49 changes: 1 addition & 48 deletions bokehjs/test/integration/regressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {PlotActions, xy, click, press, mouseenter} from "../interactive"
import type {ArrowHead, Line, Renderer, BasicTickFormatter} from "@bokehjs/models"
import {
Arrow, NormalHead, OpenHead,
BoxAnnotation, LabelSet, ColorBar, Slope, Whisker,
BoxAnnotation, ColorBar, Slope, Whisker,
Range1d, DataRange1d, FactorRange,
ColumnDataSource, CDSView, BooleanFilter, IndexFilter, Selection,
LinearAxis, CategoricalAxis,
Expand Down Expand Up @@ -570,27 +570,6 @@ describe("Bug", () => {
})

describe("in issue #10454", () => {
it("disallows using categorical coordinates with LabelSet annotation", async () => {
const p = fig([300, 300], {x_range: ["X1", "X2", "X3"], y_range: ["Y1", "Y2", "Y3"]})
p.rect({x: ["X1", "X2", "X3"], y: ["Y1", "Y2", "Y3"], width: 1, height: 1, fill_alpha: 0.3})

const labels0 = new LabelSet({x: {value: "X1"}, y: {value: "Y3"}, text: {value: "L0"}, text_color: "red"})
p.add_layout(labels0)

const labels1 = new LabelSet({x: {value: "X3"}, y: {value: "Y1"}, text: {value: "L1"}, text_color: "green"})
p.add_layout(labels1)

const source = new ColumnDataSource({data: {
x: ["X1", "X2", "X3"],
y: ["Y1", "Y2", "Y3"],
text: ["L20", "L21", "L22"],
}})
const labels2 = new LabelSet({x: {field: "x"}, y: {field: "y"}, text: {field: "text"}, source, text_color: "blue"})
p.add_layout(labels2)

await display(p)
})

it("disallows using categorical coordinates with Arrow annotation", async () => {
const p = fig([300, 300], {x_range: ["X1", "X2", "X3"], y_range: ["Y1", "Y2", "Y3"]})
p.rect({x: ["X1", "X2", "X3"], y: ["Y1", "Y2", "Y3"], width: 1, height: 1, fill_alpha: 0.3})
Expand Down Expand Up @@ -1972,32 +1951,6 @@ describe("Bug", () => {
})
})

describe("in issue #12127", () => {
it("prevents displaying non-text labels in LabelSet", async () => {
const p = fig([200, 200], {
x_range: new Range1d({start: -1, end: 2}),
y_range: new Range1d({start: -1, end: 2}),
})

const source = new ColumnDataSource({data: {
a: [0, 0, 1, 1],
b: [0, 1, 0, 1],
c: [6, 7, 8, 9],
}})

const labels = new LabelSet({
x: {field: "a"},
y: {field: "b"},
text: {field: "c"},
source,
})

p.add_layout(labels)

await display(p)
})
})

describe("in issue #12357", () => {
it("should not render size 0 webgl markers", async () => {
const x = [0, 1, 2, 3]
Expand Down
14 changes: 7 additions & 7 deletions examples/basic/scatters/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.. bokeh-example-metadata::
:sampledata: periodic_table
:apis: bokeh.plotting.figure.scatter, bokeh.models.sources.ColumnDataSource, bokeh.models.annotations.LabelSet
:apis: bokeh.plotting.figure.scatter, bokeh.plotting.figure.text, bokeh.models.sources.ColumnDataSource
:refs: :ref:`ug_interaction_tools_hover_tool`
:keywords: hover, labels, scatter
Expand Down Expand Up @@ -51,12 +51,12 @@

source = ColumnDataSource(elements)

p.scatter("atomic mass", "density", size=12, source=source,
color='melting_colors', line_color="black", alpha=0.9)
p.scatter("atomic mass", "density", size=12,
color='melting_colors', line_color="black", alpha=0.9,
source=source)

labels = LabelSet(x="atomic mass", y="density", text="symbol", y_offset=8,
text_font_size="11px", text_color="#555555",
source=source, text_align='center')
p.add_layout(labels)
p.text(x="atomic mass", y="density", text="symbol", y_offset=-8,
text_font_size="11px", text_color="#555555", text_align='center',
source=source)

show(p)
18 changes: 9 additions & 9 deletions examples/models/transform_jitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
normal = Jitter(width=0.2, distribution="normal")
uniform = Jitter(width=0.2, distribution="uniform")

p = figure(x_range=(0, 4), y_range=(0,10), toolbar_location=None, x_axis_location="above")
p = figure(x_range=(0, 4), y_range=(0,10), toolbar_location=None, x_axis_location="above", min_border_bottom=25)
p.circle(x='x', y='y', color='firebrick', source=source, size=5, alpha=0.5)

r1 = p.circle(x='xn', y='y', color='olive', source=source, size=5, alpha=0.5)
Expand All @@ -32,15 +32,15 @@
u2 = p.circle(x=field('xu', uniform), y='y', color='navy', source=source,
size=5, alpha=0.5, visible=False)

label_data = ColumnDataSource(data=dict(
x=[1,2,3], y=[0, 0, 0], t=['Original', 'Normal', 'Uniform'],
))
label_set = LabelSet(x='x', y='y', text='t', y_offset=-4, source=label_data,
text_baseline="top", text_align='center')
p.add_layout(label_set)
p.text(
x=[1, 2, 3], y=[0, 0, 0], y_offset=5,
text=["Original", "Normal", "Uniform"],
anchor="top_center",
level="annotation",
)

callback = CustomJS(args=dict(r1=r1, n1=n1, r2=r2, u2=u2), code="""
for (const r of [r1, n1, r2, u2]) {
callback = CustomJS(args=dict(renderers=[r1, n1, r2, u2]), code="""
for (const r of renderers) {
r.visible = !r.visible
}
""")
Expand Down

0 comments on commit f8557dc

Please sign in to comment.