deepscatter icon indicating copy to clipboard operation
deepscatter copied to clipboard

Add bound parameters to mouseover and click_functions.

Open bmschmidt opened this issue 4 years ago • 2 comments

Currently 'click' lets you define a function on datum, but 'mouseover' just creates a tooltip that is unaware of the local styling environment.

mouseover should instead accept a function-defining string with the arguments (datum, event, $), as in arquero, where $ refers to a bindable context on plot to allow safe (non-eval) materialization of the strings, and event is the d3 event context.

So


plot.params.select = d3.select
plot.params.make_tooltips = function(data, selector) {
const values = [...Object.entries(datum)];
const dl = d3.select(selector).selectAll("dl").data([1])
[... yadda yadda yadda ... populate <dt> <dl> items.
}
"mouseover": '$.select(".tooltip").style("transform", "translate(${datum.x}, ${datum.y}"); $.make_tooltips('

bmschmidt avatar Jun 25 '21 11:06 bmschmidt

Actually, it isn't even necessary to use "$" magic. By adding the param scope to the function creation, you can have the function.

"mouseover": 'select(".tooltip").style("transform", \translate(${datum.x}, ${datum.y}`); make_tooltips(SOMETHING)"`

bmschmidt avatar Sep 02 '21 18:09 bmschmidt

Name changed to reflect narrowing scope. Currently both these functions accept only a single argument (the datum). If there were a strong case for accepting some kind of bound parameters (e.g., the current state of the plot query) I could see baking this access in.

bmschmidt avatar Jul 18 '22 20:07 bmschmidt