Skip to content

Commit

Permalink
Fix bokehjs' property mixins to match bokeh (#10192)
Browse files Browse the repository at this point in the history
* Fix bokehjs' property mixins to match bokeh

* Change ColorBar.bar_line_* to scalar
  • Loading branch information
mattpap committed Jun 21, 2020
1 parent d0cda21 commit b7539bc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bokeh/models/annotations.py
Expand Up @@ -463,7 +463,7 @@ class ColorBar(Annotation):
main plot area.
""")

bar_props = Include(LineProps, help="""
bar_props = Include(ScalarLineProps, help="""
The %s for the color scale bar outline.
""")

Expand Down
66 changes: 33 additions & 33 deletions bokehjs/src/lib/core/property_mixins.ts
Expand Up @@ -156,10 +156,10 @@ export type LineVector = {
line_color: p.VectorSpec<Color | null>
line_alpha: p.VectorSpec<number>
line_width: p.VectorSpec<number>
line_join: p.ScalarSpec<LineJoin>
line_cap: p.ScalarSpec<LineCap>
line_dash: p.ScalarSpec<number[]>
line_dash_offset: p.ScalarSpec<number>
line_join: p.Property<LineJoin>
line_cap: p.Property<LineCap>
line_dash: p.Property<number[]>
line_dash_offset: p.Property<number>
}

export type FillVector = {
Expand All @@ -173,53 +173,53 @@ export type HatchVector = {
hatch_scale: p.VectorSpec<number>
hatch_pattern: p.VectorSpec<HatchPattern | null>
hatch_weight: p.VectorSpec<number>
hatch_extra: p.VectorSpec<HatchExtra>
hatch_extra: p.Property<HatchExtra>
}

export type TextVector = {
text_color: p.VectorSpec<Color | null>
text_alpha: p.VectorSpec<number>
text_font: p.ScalarSpec<string>
text_font: p.Property<string>
text_font_size: p.VectorSpec<string>
text_font_style: p.ScalarSpec<FontStyle>
text_align: p.ScalarSpec<TextAlign>
text_baseline: p.ScalarSpec<TextBaseline>
text_line_height: p.ScalarSpec<number>
text_font_style: p.Property<FontStyle>
text_align: p.Property<TextAlign>
text_baseline: p.Property<TextBaseline>
text_line_height: p.Property<number>
}

export const LineVector: p.DefineOf<LineVector> = {
line_color: [ p.ColorSpec, "black" ],
line_alpha: [ p.NumberSpec, 1.0 ],
line_width: [ p.NumberSpec, 1 ],
line_join: [ p.LineJoinScalar, "bevel" ],
line_cap: [ p.LineCapScalar, "butt" ],
line_dash: [ p.ArrayScalar, [] ],
line_dash_offset: [ p.NumberScalar, 0 ],
line_color: [ p.ColorSpec, "black" ],
line_alpha: [ p.NumberSpec, 1.0 ],
line_width: [ p.NumberSpec, 1 ],
line_join: [ p.LineJoin, "bevel" ],
line_cap: [ p.LineCap, "butt" ],
line_dash: [ p.Array, [] ],
line_dash_offset: [ p.Number, 0 ],
}

export const FillVector: p.DefineOf<FillVector> = {
fill_color: [ p.ColorSpec, "gray" ],
fill_alpha: [ p.NumberSpec, 1.0 ],
fill_color: [ p.ColorSpec, "gray" ],
fill_alpha: [ p.NumberSpec, 1.0 ],
}

export const HatchVector: p.DefineOf<HatchVector> = {
hatch_color: [ p.ColorSpec, "black" ],
hatch_alpha: [ p.NumberSpec, 1.0 ],
hatch_scale: [ p.NumberSpec, 12.0 ],
hatch_pattern: [ p.NullStringSpec, null ],
hatch_weight: [ p.NumberSpec, 1.0 ],
hatch_extra: [ p.AnyScalar, {} ],
hatch_color: [ p.ColorSpec, "black" ],
hatch_alpha: [ p.NumberSpec, 1.0 ],
hatch_scale: [ p.NumberSpec, 12.0 ],
hatch_pattern: [ p.NullStringSpec, null ],
hatch_weight: [ p.NumberSpec, 1.0 ],
hatch_extra: [ p.Any, {} ],
}

export const TextVector: p.DefineOf<TextVector> = {
text_color: [ p.ColorSpec, "#444444" ],
text_alpha: [ p.NumberSpec, 1.0 ],
text_font: [ p.Font, "helvetica" ],
text_font_size: [ p.FontSizeSpec, "16px" ],
text_font_style: [ p.FontStyleScalar, "normal" ],
text_align: [ p.TextAlignScalar, "left" ],
text_baseline: [ p.TextBaselineScalar, "bottom" ],
text_line_height: [ p.NumberScalar, 1.2 ],
text_color: [ p.ColorSpec, "#444444" ],
text_alpha: [ p.NumberSpec, 1.0 ],
text_font: [ p.Font, "helvetica" ],
text_font_size: [ p.FontSizeSpec, "16px" ],
text_font_style: [ p.FontStyle, "normal" ],
text_align: [ p.TextAlign, "left" ],
text_baseline: [ p.TextBaseline, "bottom" ],
text_line_height: [ p.Number, 1.2 ],
}

// Common property mixins used in models. This duplication is currently unavoidable.
Expand Down
6 changes: 3 additions & 3 deletions bokehjs/test/unit/core/visuals.ts
Expand Up @@ -18,7 +18,7 @@ describe("Fill", () => {
it(`should set canvas context ${attr} value from ${spec} spec value`, () =>{
const ctx = {} as any
const attrs = {} as any
attrs[spec] = {value}
attrs[spec] = value
const model = new Circle(attrs)
const fill = new Fill(model)
fill.set_value(ctx)
Expand Down Expand Up @@ -69,7 +69,7 @@ describe("Line", () => {
ctx.setLineDash = function(x: number) { ctx.lineDash = x }
ctx.setLineDashOffset = function(x: number) { ctx.lineDashOffset = x }
const attrs = {line_dash: [1, 2]} as any
attrs[spec] = {value}
attrs[spec] = value
const model = new Circle(attrs)
const line = new Line(model)
line.set_value(ctx)
Expand Down Expand Up @@ -120,7 +120,7 @@ describe("Text", () => {
it(`should set canvas context ${attr} value from ${spec} spec value`, () =>{
const ctx = {} as any
const attrs = {text_font: 'times', text_font_size: "16px", text_font_style: "bold"} as any
attrs[spec] = {value}
attrs[spec] = value
const model = new text_glyph.Text(attrs)
const text = new Text(model)
text.set_value(ctx)
Expand Down

0 comments on commit b7539bc

Please sign in to comment.