-
Notifications
You must be signed in to change notification settings - Fork 4
/
click_info.py
27 lines (23 loc) · 884 Bytes
/
click_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from mpld3 import plugins
from mpld3 import utils
class ClickInfo(plugins.PluginBase):
"""Plugin for getting info on click"""
JAVASCRIPT = """
mpld3.register_plugin("clickinfo", ClickInfo);
ClickInfo.prototype = Object.create(mpld3.Plugin.prototype);
ClickInfo.prototype.constructor = ClickInfo;
ClickInfo.prototype.requiredProps = ["id"];
function ClickInfo(fig, props){
mpld3.Plugin.call(this, fig, props);
};
ClickInfo.prototype.draw = function(){
var obj = mpld3.get_element(this.props.id);
obj.elements().on("mousedown",
function(d, i){alert("clicked on points[" + i + "]");});
}
"""
def __init__(self, points, urls):
self.dict_ = {"type": "clickinfo",
"id": utils.get_id(points),
"urls": urls
}