@quartic/bokehjs
Version:
Interactive, novel data visualization
49 lines (35 loc) • 1.18 kB
text/coffeescript
import {XYGlyph, XYGlyphView} from "./xy_glyph"
import * as p from "core/properties"
export class RayView extends XYGlyphView
_map_data: () ->
= (.xmapper, , )
_render: (ctx, indices, {sx, sy, slength, _angle}) ->
if .line.doit
width = .plot_view.frame.width
height = .plot_view.frame.height
inf_len = 2 * (width + height)
for i in [0...slength.length]
if slength[i] == 0
slength[i] = inf_len
for i in indices
if isNaN(sx[i]+sy[i]+_angle[i]+slength[i])
continue
ctx.translate(sx[i], sy[i])
ctx.rotate(_angle[i])
ctx.beginPath()
ctx.moveTo(0, 0)
ctx.lineTo(slength[i], 0)
.line.set_vectorize(ctx, i)
ctx.stroke()
ctx.rotate(-_angle[i])
ctx.translate(-sx[i], -sy[i])
draw_legend_for_index: (ctx, x0, x1, y0, y1, index) ->
(ctx, x0, x1, y0, y1, index)
export class Ray extends XYGlyph
default_view: RayView
type: 'Ray'
['line']
{
length: [ p.DistanceSpec ]
angle: [ p.AngleSpec ]
}