Hi,
I have added a snippet of code below. I was wondering if its possible to add the ColorPicker model inside the table for each zone? And the user selects what color it wants to use. If its not possible to add it inside the html text. Is there a way to add it in a loop? I forsee my project having maybe up to 20 different zones and user wants to be able to manually select what color the line or marker should be.
Hope someone can help or point me in a direction.
from bokeh.io import show
from bokeh.layouts import column
from bokeh.models import ColorPicker, Div
from bokeh.plotting import Figure
plot = Figure(x_range=(0, 1), y_range=(0, 1), width=350, height=350)
systems = ['Zone-1', 'Zone-2', 'Zone-3']
values = [1, 2, 3]
colors = ['red', 'blue', 'green']
htmltext = Div(text = """
<!DOCTYPE html>
<html>
<head>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #D6EEEE;
}
</style>
</head>
<body>
<h2>Change color for respectives zones below:</h2>
<table>
<tr>
<th>Zone</th>
<th>Color Picker</th>
</tr>
<tr>
<td>Zone-1</td>
<td>Colorpicker</td>
</tr>
<tr>
<td>Zone-2</td>
<td>Colorpicker</td>
</tr>
<tr>
<td>Zone-3</td>
<td>Colorpicker</td>
</tr>
</table>
</body>
</html>
""", width = 400, height = 300, style={'font-size': '100%', 'color': 'black'})
def plotter(systems, colors):
for name, color, val in zip(sorted(systems), colors, values):
print(name, color, val)
line = plot.line(x=(0,val + 1), y=(0,1), color=color, line_width=4, legend_label = name)
picker = ColorPicker(title=name)
picker.js_link('color', line.glyph, 'line_color')
return line, picker
line, picker = plotter(systems, colors)
show(column(plot, htmltext, picker))