コード例 #1
0
 def test_context(self):
     d = document.Document()
     p = PlotContext()
     d.context = p
     self.assertEqual(d.context, p)
     d._models['foo'] = PlotContext()
     self.assertRaises(TypeError, setattr, d, "context", "foo")
     self.assertRaises(DataIntegrityException, setattr, d, "context", p)
コード例 #2
0
ファイル: docs.py プロジェクト: xuexianwu/bokeh
def new_doc(flaskapp, docid, title, clientdoc, rw_users=None, r_users=None,
            apikey=None, readonlyapikey=None):
    if not apikey: apikey = str(uuid.uuid4())
    if not readonlyapikey: readonlyapikey = str(uuid.uuid4())
    plot_context = PlotContext()
    clientdoc.context = plot_context
    if rw_users is None: rw_users = []
    if r_users is None: r_users = []
    doc = Doc(docid, title, rw_users, r_users,
              plot_context.ref, apikey, readonlyapikey)
    doc.save(flaskapp.servermodel_storage)
    return doc
コード例 #3
0
def large_plot(n):
    from bokeh.models import (Plot, PlotContext, LinearAxis, Grid,
                              GlyphRenderer, ColumnDataSource, DataRange1d,
                              PanTool, WheelZoomTool, BoxZoomTool,
                              BoxSelectTool, BoxSelectionOverlay, ResizeTool,
                              PreviewSaveTool, ResetTool)
    from bokeh.models.glyphs import Line

    context = PlotContext()
    objects = set([context])

    for i in xrange(n):
        source = ColumnDataSource(data=dict(x=[0, i + 1], y=[0, i + 1]))
        xdr = DataRange1d(sources=[source.columns("x")])
        ydr = DataRange1d(sources=[source.columns("y")])
        plot = Plot(x_range=xdr, y_range=ydr)
        xaxis = LinearAxis(plot=plot)
        yaxis = LinearAxis(plot=plot)
        xgrid = Grid(plot=plot, dimension=0)
        ygrid = Grid(plot=plot, dimension=1)
        tickers = [
            xaxis.ticker, xaxis.formatter, yaxis.ticker, yaxis.formatter
        ]
        glyph = Line(x='x', y='y')
        renderer = GlyphRenderer(data_source=source, glyph=glyph)
        plot.renderers.append(renderer)
        pan = PanTool(plot=plot)
        wheel_zoom = WheelZoomTool(plot=plot)
        box_zoom = BoxZoomTool(plot=plot)
        box_select = BoxSelectTool(plot=plot)
        box_selection = BoxSelectionOverlay(tool=box_select)
        resize = ResizeTool(plot=plot)
        previewsave = PreviewSaveTool(plot=plot)
        reset = ResetTool(plot=plot)
        tools = [
            pan, wheel_zoom, box_zoom, box_select, box_selection, resize,
            previewsave, reset
        ]
        plot.tools.append(tools)
        context.children.append(plot)
        objects |= set([
            source, xdr, ydr, plot, xaxis, yaxis, xgrid, ygrid, renderer,
            glyph, plot.tool_events
        ] + tickers + tools)

    return context, objects