I noticed that selection_color
sticks for my full code, but I store that in the CDS. So I tried the following, which works. Is the previous code expected behavior though?
from bokeh.io import show
from bokeh.models import ColumnDataSource, DataTable, TableColumn
from bokeh.plotting import figure
from bokeh.layouts import column
x = [0, 1, 2, 3, 4, 5, 6]
y1 = [i**2 for i in x]
y2 = [i**3 for i in x]
source = ColumnDataSource(dict(x=[x, x],
y=[y1, y2],
line_width=[1, 1],
line_dash=['solid', 'solid']))
fig = figure()
renderer = fig.multi_line('x', 'y', source=source, nonselection_alpha=0.3, selection_alpha=1, line_width='line_width')
columns = [TableColumn(field='x', title='X Values'),
TableColumn(field='y', title='Y Values')]
table = DataTable(source=source, columns=columns)
source.data['line_width'] = [10, 10]
source.data['line_dash'] = ['dashed', 'dashed']
layout = column(fig, table)
show(layout)
Update:
Sorry one more comment. I forgot to include line_dash='line_dash'
when initializing multi_line
. If I do include it, I get a crash.
from bokeh.io import show
from bokeh.models import ColumnDataSource, DataTable, TableColumn
from bokeh.plotting import figure
from bokeh.layouts import column
x = [0, 1, 2, 3, 4, 5, 6]
y1 = [i**2 for i in x]
y2 = [i**3 for i in x]
source = ColumnDataSource(dict(x=[x, x],
y=[y1, y2],
line_width=[1, 1],
line_dash=['solid', 'solid']))
fig = figure()
renderer = fig.multi_line('x', 'y', source=source, nonselection_alpha=0.3, selection_alpha=1,
line_width='line_width', line_dash='line_dash')
columns = [TableColumn(field='x', title='X Values'),
TableColumn(field='y', title='Y Values')]
table = DataTable(source=source, columns=columns)
source.data['line_width'] = [10, 10]
source.data['line_dash'] = ['dashed', 'dashed']
layout = column(fig, table)
show(layout)
Traceback (most recent call last):
File "<input>", line 18, in <module>
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/plotting/_decorators.py", line 54, in wrapped
return create_renderer(glyphclass, self, **kwargs)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/plotting/_renderer.py", line 118, in create_renderer
glyph=make_glyph(glyphclass, kwargs, glyph_visuals),
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/plotting/_renderer.py", line 137, in make_glyph
return glyphclass(**kws)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/model.py", line 234, in __init__
super().__init__(**kwargs)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/has_props.py", line 247, in __init__
setattr(self, name, value)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/has_props.py", line 274, in __setattr__
super().__setattr__(name, value)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/property/descriptors.py", line 539, in __set__
self._internal_set(obj, value, setter=setter)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/property/descriptors.py", line 760, in _internal_set
value = self.property.prepare_value(obj, self.name, value)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/property/bases.py", line 331, in prepare_value
raise e
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/property/bases.py", line 324, in prepare_value
self.validate(value)
File "/Users/ninja/PycharmProjects/DVH-Analytics/venv_bokeh/lib/python3.6/site-packages/bokeh/core/property/either.py", line 109, in validate
raise ValueError(msg)
ValueError: expected an element of either Enum('solid', 'dashed', 'dotted', 'dotdash', 'dashdot'), Regex('^(\\d+(\\s+\\d+)*)?$') or Seq(Int), got 'line_dash'