hello!
so…i’ve been putting this off for a while, but i’m returning to a project that’s been…on hold for a bit and…well…i really want my damn custom marker.
so…when figured out that i couldn’t quite get the stock markers to do exactly what i needed, i popped into…whatever the live chat for bokeh is and one of the devs was kind enough to quickly throw together the below:
from bokeh.models import Marker
JS_CODE = """
import {Marker, MarkerView} from "models/markers/marker"
export class MyTriangleView extends MarkerView
_render_one: (ctx, i, r, line, fill) ->
h = r * Math.sqrt(3)
a = h
ctx.moveTo(-r, a)
ctx.lineTo(r, a)
ctx.lineTo(0, a - h)
ctx.closePath()
if (fill.doit)
fill.set_vectorize(ctx, i)
ctx.fill()
if (line.doit)
line.set_vectorize(ctx, i)
ctx.stroke()
export class BuySell extends Marker
default_view: MyTriangleView
type: "BuySell"
"""
class BuySell(Marker):
__implementation__ = JS_CODE
i remember seeing the dreaded “we’re going to be deprecating this…so get your shit together with this custom JS marker.” but life and i had to put the project on hiatus. i think even at the time, the documentation for what the dev did…didn’t really exist…sort of an in-house hookup, if you will. I’ve tried giving the documentation another college try, to no avail. i’m either missing something or i just don’t know wtf i’m supposed to be searching for.
that said, i suppose i have the following:
- how does one implement custom markers with the current stable bokeh release?
- if there is documentation, please for the love of superman point the way.
- if there is not, how in the name of kelly clarkson does one refactor the above for python?
i sort of just #yolo’d the below, but i have a feeling it’s…you know…not correct.
class BSTriangle(MarkerView):
def __init__(self, ctx, i, r, line, fill):
self.ctx = ctx
self.i = i
self.r = r
self.line = line
self.fill = fille
def _render_one(self):
h = r * math.sqrt(3)
a = h
ctx.moveTo(-r, a)
ctx.lineTo(r, a)
ctx.lineTo(0, a - h)
ctx.closePath()
if fill.doit:
fill.set_vectorize(ctx, i)
if line.doit:
line.set_vectorixe(ctx, i)
ctx.stroke()
class BuySell(Marker):
def __init__(self):
self.default_view = BSTriangle
self.type = 'BuySell'
help me obi wan(s)!