Just to clarify, when I say the Hovertool is sketchy, specifically I mean the labels do not consistently display. In the console the following exceptions are frequent:
Uncaught TypeError: Cannot read property ‘length’ of undefined
at LineView.exports.LineView.LineView._hit_point (line.js:63)
at LineView.exports.GlyphView.GlyphView.hit_test (glyph.js:245)
at GlyphRendererView.exports.GlyphRendererView.GlyphRendererView.hit_test (glyph_renderer.js:245)
at SelectionManager.exports.SelectionManager.SelectionManager.inspect (selection_manager.js:55)
at HoverToolView.exports.HoverToolView.HoverToolView._inspect (hover_tool.js:94)
at HoverToolView.exports.HoverToolView.HoverToolView._move (hover_tool.js:63)
at triggerEvents (events.js:245)
at triggerApi (events.js:227)
at eventsApi (events.js:44)
at UIEvents.exports.Events.trigger (events.js:216)
the function throws referencing this.sx in the for loop; there is no sx property on the object:
LineView.prototype._hit_point = function (geometry) {
/* Check if the point geometry hits this line glyph and return an object
that describes the hit result:
Args:
-
geometry (object): object with the following keys
-
vx (float): view x coordinate of the point
-
vy (float): view y coordinate of the point
-
type (str): type of geometry (in this case it’s a point)
Output:
Object with the following keys:
*/
var dist, i, j, p0, p1, point, ref, ref1, result, shortest, threshold;
result = hittest.create_hit_test_result();
point = {
x: this.renderer.plot_view.canvas.vx_to_sx(geometry.vx),
y: this.renderer.plot_view.canvas.vy_to_sy(geometry.vy)
};
shortest = 9999;
threshold = Math.max(2, this.visuals.line.line_width.value() / 2);
for (i = j = 0, ref = this.sx.length - 1; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
ref1 = [
{
x: this.sx[i],
y: this.sy[i]
}, {
x: this.sx[i + 1],
y: this.sy[i + 1]
}
], p0 = ref1[0], p1 = ref1[1];
dist = hittest.dist_to_segment(point, p0, p1);
if (dist < threshold && dist < shortest) {
shortest = dist;
result[‘0d’].glyph = this.model;
result[‘0d’].get_view = (function () {
return this;
}).bind(this);
result[‘0d’].flag = true;
result[‘0d’].indices = [i];
}
}
return result;
};
···
On Tuesday, January 3, 2017 at 10:14:35 AM UTC-8, [email protected] wrote:
I seem to have hit the exact same issue as Matteo and would appreciate digging in a little further.
I have a dataframe of multi-dimensional data, where the levels are something like source, destination, channel, stat. I use widgets that allow the user to select subsets of the values at each level, and the desire then is to just plot / display the selected stats. In total there are hundreds of columns (N source x N dest X N channels X N stats), and I generally only want to display a number of them simultaneously else the chart is too cluttered for practical use.
Currently I flatten the MultiIndex (i…e so each column has a string name like ‘node1, node2’, channel1, offload_queue_length’, and then create a ColumnDataSource from it. Then I iterate over the columns in the ColumnDataSource and add a line renderer to each plot, where x=‘index’, y=‘the flattened column name’, source=theColumnDataSource, and visible=False. Keeping a dictionary of the column names to renderer mapping allows me to easily adjust the visible attribute in the callbacks.
This works reasonably well, with the exception of performance and the Hovertool. Performance is obvious, creating all the renderers takes several seconds. For the HoverTool, responsiveness is sketchy even if I filter the .renderers property down to just the visible ones.
What I would love to do would be to only have renderers for the selected items, and then for example add circle glyphs for the hover tool to hopefully work better with. But I can’t see adding all those additional renderers to the plot and working with the visibility attributes - that would push performance too far down.
I wonder if I can dynamically change the y attribute of a renderer to point to different column_names in the dataset, and then just add renderers to the plot equal to the max number of columns selected - and then dynamically update the renderer → column mappings. I suppose I’ll give this a shot, but man it would sure be nice to be able to add and remove renderers from the plot directly. Or maybe I should just be adding a new plot each time in the callback?
Thanks for any input!
-terry
On Tuesday, April 26, 2016 at 3:57:17 AM UTC-7, [email protected] wrote:
Hello everyone,
I’m experimenting with Bokeh server. I have a document with three figures and I’m trying to update two of them depending on the selection I
perform on the third. The number of lines to plot in the two figures changes every time.
If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line. Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.
So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.
There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message…). But if it was possible to just clear and update
single figures, everything would be cleaner. I couldn’t find anything in the docs, however.
I hope the description is clear enough. I can post some minimal example if needed, of course, I just need some time to strip down the code.
Thanks in advance for your advice,
Matteo
PS: I asked the same question on SO (http://stackoverflow.com/questions/36765561/remove-renderers-from-plot), and I will try to update this discussion if something interesting is posted there, and v.v.