Skip to content

Add new child to existing column #5518

Description

@mrocklin

When adding a child plot to an existing column and then updating the plot appears but then I get the following error:

bokeh.server.protocol.server_handler - ERROR - error handling message Message 'PATCH-DOC' (revision 1): RuntimeError('Cannot apply patch to 8cf5ddd0-9b96-49fc-8099-c792733d0ff5 which is not in the document',)

And my figures come out wonky:

image

 
    def __init__(...):
        ...
        self.sizing_mode = 'scale_width'
        self.figures = {}
        self.sources = {}
        self.root = column(sizing_mode=self.sizing_mode)

    def add_figure(self, name):
        source = ColumnDataSource({'x': [], 'y': []})
        fig = figure(title=name, tools='', height=150, sizing_mode=self.sizing_mode)
        fig.line(source=source, x='x', y='y')
        self.sources[name] = source
        self.figures[name] = fig
        self.root.children = self.root.children + [fig]

    def update(self):
        for name, counter in self.server.counters.items():
            if name not in self.figures:
                self.add_figure(name)
            else:
                xs = [counter.quantile(i / 100) for i in range(101)]
                ys = [xs[i + 1] - xs[i] for i in range(len(xs) - 1)]
                self.sources[name].data.update({'x': xs, 'y': ys})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions