I have a bokeh chart that starts out with 7 line series in a chart. A select widget changes the data and shows only 4 series via a customjs callback

```
for i in range(7):
    if i < 4:
        js_code += """data['y%d']=data.%s;""" % (i,newseriesnames[i])
    js_code += """line%d.visible = %s;""" % (i,'true' if i < 4 else 'false')
js_code += 'source.change.emit();'
callback = CustomJS(args = args,code=js_code)
select.js_on_change('value',callback)

```

where `line0` through `line6` are the lines in the plot linked to data objects `data['y0']` through `data['y6']` and `select` is a bokeh selector widget.

This works great in the bokeh chart itself, but it doesn't update the legend. The legend is always the same as when it is first rendered. It retains the 7 elements. Even when they are hidden in the chart.

Things I have tried to update the legend:

1. Setting `legend.items[4].renderers[0].visible=false`
2. Setting `legend.items[4].visible=false`
3. Calling `legend.change.emit()`, `legend.items[4].change.emit()`, and `legend.items[4].renderers[0].change.emit()`
4. Overwriting the legend with a different one made using bokeh's python `Legend()` method

Note that I'm not getting any errors with these calls, they just don't produce any difference in the legend. Adding multiple legends and hiding/unhiding them works, except the placement of them is wrong when using `plot.add_layout()`

I would rather not do this using an interactive server, and would rather use the client side to do the switching. My use case is frequent going back and forth, and may want to have offline capability.

Can anyone point me in the right direction? I tested this in bokeh 0.12.16 and 0.13.0 in python 3.6.5.

Thanks