Exemple #1
0
    def render(self):
        source = self.source.dataSource()
        rend = ContinuumModel("Plot")
        _x_dr_ = ContinuumModel("DataRange1d", sources=[{"ref": source.ref(), "columns": ["x"]}])
        _y_dr_ = ContinuumModel("DataRange1d", sources=[{"ref": source.ref(), "columns": ["y"]}])

        glyph_renderer = ContinuumModel(
            "GlyphRenderer",
            data_source=source.ref(),
            xdata_range=_x_dr_.ref(),
            ydata_range=_y_dr_.ref(),
            glyphspec={
                "type": "circle",
                "units": "screen",
                "x": {"field": "x"},
                "y": {"field": "y"},
                "fill": {"field": "color"},
                "radius": {"field": "radius"},
            },
        )

        xLinearAxis = ContinuumModel("LinearAxis", parent=rend.ref(), data_range=_x_dr_.ref(), orientation="bottom")
        yLinearAxis = ContinuumModel("LinearAxis", parent=rend.ref(), data_range=_y_dr_.ref(), orientation="left")

        rend.set("renderers", [glyph_renderer.ref()])
        rend.set("axes", [xLinearAxis.ref(), yLinearAxis.ref()])
        p.bbclient.upsert_all([glyph_renderer, source, rend, _x_dr_, _y_dr_, xLinearAxis, yLinearAxis])
        p.show(rend)
Exemple #2
0
    color = 'black',
    x = 'x',
    y = 'y',
    glyphs = [{'type' : 'circles',
               'color' : 'blue'}]
    )         

xaxis = ContinuumModel(
    'LinearAxis', 
    orientation='bottom',
    parent=plot.ref(),
    data_range=xdr.ref()
    )

yaxis = ContinuumModel(
    'LinearAxis', 
    orientation='left',
    parent=plot.ref(),
    data_range=ydr.ref()
    )
plot.set('renderers', [glyph_renderer.ref()])
plot.set('axes', [xaxis.ref(), yaxis.ref()])

p.bbclient.upsert_all([source, plot, xdr, ydr, glyph_renderer, xaxis, yaxis])
p.show(plot)