@quartic/bokehjs
Version:
Interactive, novel data visualization
43 lines (32 loc) • 1.09 kB
text/coffeescript
import {RBush} from "core/util/spatial"
import {Glyph, GlyphView} from "./glyph"
export class SegmentView extends GlyphView
_index_data: () ->
points = []
for i in [0....length]
if not isNaN([i] + [i] + [i] + [i])
points.push({
minX: Math.min([i], [i]),
minY: Math.min([i], [i]),
maxX: Math.max([i], [i]),
maxY: Math.max([i], [i]),
i: i
})
return new RBush(points)
_render: (ctx, indices, {sx0, sy0, sx1, sy1}) ->
if .line.doit
for i in indices
if isNaN(sx0[i]+sy0[i]+sx1[i]+sy1[i])
continue
ctx.beginPath()
ctx.moveTo(sx0[i], sy0[i])
ctx.lineTo(sx1[i], sy1[i])
.line.set_vectorize(ctx, i)
ctx.stroke()
draw_legend_for_index: (ctx, x0, x1, y0, y1, index) ->
(ctx, x0, x1, y0, y1, index)
export class Segment extends Glyph
default_view: SegmentView
type: 'Segment'
[['x0', 'y0'], ['x1', 'y1']]
['line']