8000 Redesign "materialization" of data specs by mattpap · Pull Request #10235 · bokeh/bokeh · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits 8000
Select commit Hold shift + click to select a range
7b2c9d5
Explicitly define glyph coordinates
mattpap Jun 14, 2020
49fbf63
Add default values
mattpap Jun 26, 2020
2511c9d
Don't check for nulls in MultiLine._index_data()
mattpap Jun 26, 2020
5f03f5a
Wrap only plain object default values
mattpap Jun 26, 2020
6d12421
Make data projection explicit
mattpap Jun 26, 2020
9196019
Clean up HexTile._set_data()
mattpap Jun 26, 2020
8f3a4e0
Add support for ragged arrays
mattpap Jun 26, 2020
f267b68
Encode dimension in coordinate specs
mattpap Jun 26, 2020
1be6b51
Explicit data materialization
mattpap Jun 27, 2020
35ec95a
Update incomplete unit tests
mattpap Jun 27, 2020
e2c650c
Update graph layout providers
mattpap Jul 5, 2020
b20dfb7
Fail safe when a column is missing
mattpap Jul 5, 2020
66549c6
Use NumberArray.set() in ImageURL
mattpap Jun 24, 2020
7f79d55
Update incomplete glyph tests
mattpap Jul 5, 2020
bc46b45
Assert number arrays in corner cases
mattpap Jul 5, 2020
84a3d68
Fix glyphs' defaults
mattpap Jul 5, 2020
54d988e
Explicit defaults in {V,H}Bar glyphs
mattpap Jul 5, 2020
361686b
Respect packed colors in webgl backend
mattpap Jul 5, 2020
3569c22
Unify handling of colors and alpha
mattpap Jul 6, 2020
e059b4a
Use CoordinateSeqSeqSeqSpec for multi polygons
mattpap Jul 6, 2020
709eed9
Make toStringTag static
mattpap Jul 6, 2020
fbf4f0c
Increase pixel allowance
mattpap Jul 7, 2020
5f1c988
Respect glyph protocol in graph renderer
mattpap Jul 8, 2020
81aa324
Ignore early glyph positional defaults
mattpap Jul 9, 2020
d19f28c
Mark export selenium tests as flaky
mattpap Jul 9, 2020
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
Prev Previous commit
Next Next commit
Make data projection explicit
  • Loading branch information
mattpap committed Jul 8, 2020
commit 6d1242126a3de55f844d9bbd75a69c0d632082d8
32 changes: 25 additions & 7 deletions bokehjs/src/lib/core/util/projections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,35 @@ export function in_bounds(value: number, dimension: LatLon): boolean {
return min < value && value < max
}

export namespace inplace {
export function project_xy(x: Arrayable<number>, y: Arrayable<number>, merc_x?: Arrayable<number>, merc_y?: Arrayable<number>): void {
const n = min(x.length, y.length)
merc_x = merc_x ?? x
merc_y = merc_y ?? y
for (let i = 0; i < n; i++) {
const xi = x[i]
const yi = y[i]
const [merc_xi, merc_yi] = wgs84_mercator.compute(xi, yi)
merc_x[i] = merc_xi
merc_y[i] = merc_yi
}
}

export function project_xsys(xs: Arrayable<number>[], ys: Arrayable<number>[], merc_xs?: Arrayable<number>[], merc_ys?: Arrayable<number>[]): void {
const n = min(xs.length, ys.length)
merc_xs = merc_xs ?? xs
merc_ys = merc_ys ?? ys
for (let i = 0; i < n; i++) {
project_xy(xs[i], ys[i], merc_xs[i], merc_ys[i])
}
}
}

export function project_xy(x: Arrayable<number>, y: Arrayable<number>): [NumberArray, NumberArray] {
const n = min(x.length, y.length)
const merc_x = new NumberArray(n)
const merc_y = new NumberArray(n)
for (let i = 0; i < n; i++) {
const xi = x[i]
const yi = y[i]
const [merc_xi, merc_yi] = wgs84_mercator.compute(xi, yi)
merc_x[i] = merc_xi
merc_y[i] = merc_yi
}
inplace.project_xy(x, y, merc_x, merc_y)
return [merc_x, merc_y]
}

Expand Down
6 changes: 6 additions & 0 deletions bokehjs/src/lib/models/glyphs/bezier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {SpatialIndex} from "core/util/spatial"
import {Context2d} from "core/util/canvas"
import {Glyph, GlyphView, GlyphData} from "./glyph"
import {generic_line_legend} from "./utils"
import {inplace} from "core/util/projections"
import * as p from "core/properties"

// algorithm adapted from http://stackoverflow.com/a/14429749/3406693
Expand Down Expand Up @@ -101,6 +102,11 @@ export class BezierView extends GlyphView {
model: Bezier
visuals: Bezier.Visuals

protected _project_data(): void {
inplace.project_xy(this._x0, this._y0)
inplace.project_xy(this._x1, this._y1)
}

protected _index_data(index: SpatialIndex): void {
const {data_size} = this

Expand Down
15 changes: 3 additions & 12 deletions bokehjs/src/lib/models/glyphs/glyph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {HitTestResult} from "core/hittest"
import * as p from "core/properties"
import * as bbox from "core/util/bbox"
import * as proj from "core/util/projections"
import * as visuals from "core/visuals"
import * as geometry from "core/geometry"
import {Context2d} from "core/util/canvas"
Expand Down Expand Up @@ -238,6 +237,8 @@ export abstract class GlyphView extends View {
return new Selection({indices})
}

protected _project_data(): void {}

set_data(source: ColumnarDataSource, indices: number[], indices_to_update: number[] | null): void {
let data = this.model.materialize_dataspecs(source)

Expand Down Expand Up @@ -269,17 +270,7 @@ export abstract class GlyphView extends View {
// TODO (bev) Should really probably delegate computing projected
// coordinates to glyphs, instead of centralizing here in one place.
if (this.renderer.plot_view.model.use_map) {
if (self._x != null)
[self._x, self._y] = proj.project_xy(self._x, self._y)

if (self._xs != null)
[self._xs, self._ys] = proj.project_xsys(self._xs, self._ys)

if (self._x0 != null)
[self._x0, self._y0] = proj.project_xy(self._x0, self._y0)

if (self._x1 != null)
[self._x1, self._y1] = proj.project_xy(self._x1, self._y1)
this._project_data()
}

function num_array(array: Arrayable<number>): NumberArray {
Expand Down
6 changes: 5 additions & 1 deletion bokehjs/src/lib/models/glyphs/hex_tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Context2d} from "core/util/canvas"
import {SpatialIndex} from "core/util/spatial"
import {Line, Fill} from "core/visuals"
import {HexTileOrientation} from "core/enums"
import {inplace} from "core/util/projections"

import {generic_area_legend} from "./utils"
import {Selection} from "../selections/selection"
Expand Down Expand Up @@ -45,7 +46,6 @@ export class HexTileView extends GlyphView {
return [scx, scy]
}


protected _set_data(): void {
const n = this._q.length

Expand All @@ -68,6 +68,10 @@ export class HexTileView extends GlyphView {
}
}

protected _project_data(): void {
inplace.project_xy(this._x, this._y)
}

protected _index_data(index: SpatialIndex): void {
let ysize = this.model.size
let xsize = Math.sqrt(3)*ysize/2
Expand Down
5 changes: 5 additions & 0 deletions bokehjs/src/lib/models/glyphs/multi_line.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {SpatialIndex} from "core/util/spatial"
import {inplace} from "core/util/projections"
import {PointGeometry, SpanGeometry} from "core/geometry"
import {LineVector} from "core/property_mixins"
import {Line} from "core/visuals"
Expand Down Expand Up @@ -26,6 +27,10 @@ export class MultiLineView extends GlyphView {
model: MultiLine
visuals: MultiLine.Visuals

protected _project_data(): void {
inplace.project_xsys(this._xs, this._ys)
}

protected _index_data(index: SpatialIndex): void {
const {data_size} = this

Expand Down
E517
4 changes: 4 additions & 0 deletions bokehjs/src/lib/models/glyphs/multi_polygons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class MultiPolygonsView extends GlyphView {

protected _hole_index: SpatialIndex

protected _project_data(): void {
// TODO
}

protected _index_data(index: SpatialIndex): void {
const {min, max} = Math
const {data_size} = this
Expand Down
5 changes: 5 additions & 0 deletions bokehjs/src/lib/models/glyphs/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as hittest from "core/hittest"
import * as p from "core/properties"
import {Selection} from "../selections/selection"
import {unreachable} from "core/util/assert"
import {inplace} from "core/util/projections"

export interface PatchesData extends GlyphData {
_xs: NumberArray[]
Expand All @@ -26,6 +27,10 @@ export class PatchesView extends GlyphView {
model: Patches
visuals: Patches.Visuals

protected _project_data(): void {
inplace.project_xsys(this._xs, this._ys)
}

protected _index_data(index: SpatialIndex): void {
const {data_size} = this

Expand Down
6 changes: 6 additions & 0 deletions bokehjs/src/lib/models/glyphs/quadratic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {LineVector} from "core/property_mixins"
import {Line} from "core/visuals"
import {Rect, NumberArray} from "core/types"
import {SpatialIndex} from "core/util/spatial"
import {inplace} from "core/util/projections"
import {Context2d} from "core/util/canvas"
import {Glyph, GlyphView, GlyphData} from "./glyph"
import {generic_line_legend} from "./utils"
Expand Down Expand Up @@ -49,6 +50,11 @@ export class QuadraticView extends GlyphView {
model: Quadratic
visuals: Quadratic.Visuals

protected _project_data(): void {
inplace.project_xy(this._x0, this._y0)
inplace.project_xy(this._x1, this._y1)
}

protected _index_data(index: SpatialIndex): void {
const {data_size} = this

Expand Down
6 changes: 6 additions & 0 deletions bokehjs/src/lib/models/glyphs/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {LineVector} from "core/property_mixins"
import {Line} from "core/visuals"
import {Arrayable, Rect, NumberArray} from "core/types"
import {SpatialIndex} from "core/util/spatial"
import {inplace} from "core/util/projections"
import {Context2d} from "core/util/canvas"
import {Glyph, GlyphView, GlyphData} from "./glyph"
import {generic_line_legend} from "./utils"
Expand All @@ -28,6 +29,11 @@ export class SegmentView extends GlyphView {
model: Segment
visuals: Segment.Visuals

protected _project_data(): void {
inplace.project_xy(this._x0, this._y0)
inplace.project_xy(this._x1, this._y1)
}

protected _index_data(index: SpatialIndex): void {
const {min, max} = Math
const {data_size} = this
Expand Down
5 changes: 5 additions & 0 deletions bokehjs/src/lib/models/glyphs/xy_glyph.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {NumberArray} from "core/types"
import {SpatialIndex} from "core/util/spatial"
import {inplace} from "core/util/projections"
import * as p from "core/properties"
import {Glyph, GlyphView, GlyphData} from "./glyph"

Expand All @@ -17,6 +18,10 @@ export abstract class XYGlyphView extends GlyphView {
model: XYGlyph
visuals: XYGlyph.Visuals

protected _project_data(): void {
inplace.project_xy(this._x, this._y)
}

protected _index_data(index: SpatialIndex): void {
const {data_size} = this

Expand Down
0