question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't update multi_line datasource dynamically

See original GitHub issue

I have the following code to update a multi-line plot dynamically:

xs, ys = get_xs_ys_for(event)
source = ColumnDataSource(dict(xs=xs, ys=ys))

def ticker_change(attrname, old, new):
    xs, ys = get_xs_ys_for(new)
    source.data = dict(x=xs, ys=ys)
ticker.on_change('value', ticker_change)

fig = figure(title='Individual Lines', height=450)
plot = fig.multi_line(xs, ys, source=source, line_width=5, line_color=Spectral11)

However, the update is not reflected in the multi-line plot when I change the ticker (it keeps the old lines). I’m wondering if it is a bug (because it works with one line (using fig.line())?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Oct 21, 2016

You can set the line color but you need to put the colors in the source. Behaviours like this are why this mixed list literal / explicit source usage is being disallowed. In brief the problem is this: the original glyph method call constructs a column for line_color but your update function only has x and y columns. So then the plot looks for a (now non-existent) column for line color, and breaks.

1reaction
birdsarahcommented, Oct 21, 2016

Right. OK that was the point I was trying to make I just missed the line_color thing being wrong too.

So this is wrong:

plot = fig.multi_line(xs, ys, source=source, line_width=5, line_color=Spectral11)

this is wrong:

plot = fig.multi_line(xs='xs', ys='ys', source=source, line_width=5, line_color=Spectral11)

this is right:

plot = fig.multi_line(xs='xs', ys='ys', source=source, line_width=5, line_color='color')

ALTERNATIVELY

You could do this which pulls the source that’s been created for you out:

xs, ys = get_xs_ys_for(all_events[0])
fig = figure(title='Individual CPUs', height=450)
lines = fig.multi_line(xs=xs, ys=ys, line_width=5, line_color=Spectral11)
source = lines.data_source

def ticker_change_bad(attrname, old, new):
   # DON'T DO THIS
    xs, ys = get_xs_ys_for(new)
    source.data['xs'] = xs
    source.data['ys'] = ys

def ticker_change_good(attrname, old, new):
    xs, ys = get_xs_ys_for(new)
    source.data = dict(xs=xs, ys=ys, line_color=Spectral11)

# The two ticker change methods should be equivalent. I'm not 100% sure what the name of the #column will be when the source is auto-generated for you.

ticker.on_change('value', ticker_change_good)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating multiple line plots dynamically in callback in bokeh
I am guessing because in the new data source, the pay_conv_7d.content column doesn't exist, but in my plot those lines were already there....
Read more >
Power Automate: Add and update data in bulk - YouTube
Your browser can't play this video. ... Then you modify the flow to also update existing items and create new ones.
Read more >
Multi Line Chart Functionality - Ext.NET Forums
Hello, I am trying to create a multi-line chart and the existing functionality doesn't seem to support how I want to produce the...
Read more >
How Analysis Works for Multi-table Data Sources that Use ...
Using a data source that has multiple, related tables affects how analysis works in Tableau. Because multiple, related tables have independent domains and ......
Read more >
How to use Dynamic SQL in BigQuery - Towards Data Science
So, you can't pass in a column name through USING. Hence, I recommend using String FORMAT() to create the query to execute immediately...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found