@quartic/bokehjs
Version:
Interactive, novel data visualization
35 lines (28 loc) • 933 B
text/coffeescript
import {RBush} from "core/util/spatial"
import {Glyph, GlyphView} from "./glyph"
import {CategoricalMapper} from "../mappers/categorical_mapper"
export class XYGlyphView extends GlyphView
_index_data: () ->
# if the range is categorical, map to synthetic coordinates first
if .xmapper instanceof CategoricalMapper
xx = .xmapper.v_map_to_target(, true)
else
xx =
if .ymapper instanceof CategoricalMapper
yy = .ymapper.v_map_to_target(, true)
else
yy =
points = []
for i in [0...xx.length]
x = xx[i]
if isNaN(x) or not isFinite(x)
continue
y = yy[i]
if isNaN(y) or not isFinite(y)
continue
points.push({minX: x, minY: y, maxX: x, maxY: y, i: i})
return new RBush(points)
export class XYGlyph extends Glyph
type: "XYGlyph"
default_view: XYGlyphView
[['x', 'y']]