Wondering if anyone has considered making a hybrid of the TapTool and the HoverTool that would work in place of hover over for use on a mobile browser / if this would be a workable idea.
Been putting together a little swell browser, using hover tool to control linked data on seperate plots and also display data as a tooltip:
https://swellspect.herokuapp.com/ (look at the height plot).
This takes advantage of the cb_data object in the js callback:
update_ts = CustomJS(args=dict(sourcedata=sourcedata),
code="""
function degToCompass(num) {
var val = Math.floor((num / 22.5) + 0.5);
var arr = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"];
return arr[(val % 16)].concat(" (", Math.round(num).toString(), ")");
}
function degToCompassArr(arr){
var arro = [];
for (var i = 0; i<arr.length; i++){
arro[i]=degToCompass(arr[i]);
}
return arro;
}
var y = cb_data.geometry.y;
var x = cb_data.geometry.x;
var c = Math.round(-y*24);
var data = sourcedata.get('data')
var paxis = data['paxis'];
var y2disp_ts = data['y'];
var amp = data['amp'];
var timey = data['b'];
for (i = 0; i < paxis.length; i++) {
y2disp_ts[i] = amp[c][i];
timey[i]=y;
}
var dir = data['dir'];
data['y'] = y2disp_ts;
data['hh']=amp[Math.round(-y*24)];
data['dd']=degToCompassArr(dir[Math.round(-y*24)]);
sourcedata.trigger('change');
""")
fig2_hovertool = fig2.select(type=HoverTool)
fig2_hovertool.callback = update_ts
fig2_hovertool.point_policy = "follow_mouse"
fig2_hovertool.mode = "mouse"
fig2_hovertool.tooltips=OrderedDict([
("Days Back", "$y"),
("Period", "@paxis"),
("Height", "@hh ft"),
("Direction", "@dd")
])
``
Thoughts:
-
My first idea is that could be passed to the tap tool, so one could do something similar with the 'geometry . I havn’t jumped into the source yet but would be willing to try hacking this together if there isn’t already a solution out there.
-
A second idea would be to implement tool tips for the tap tool. (Not sure how feasible this might be, but would probably rely on 1) as well).
-
What about a special mobile friendly TapNStay tool that basically wrapps the hover tool like functionality accessible to a touch screen?
-
Designers would probably suggest I go lie under a bus because such hover nonsense is counter to their ideology.
