var regionHeight = Math.abs(dragEndY - dragStartY);
if (regionWidth < 2 && regionHeight < 2 && self.lastx_ != undefined) {
+ // TODO(danvk): pass along more info about the points, e.g. 'x'
if (self.attr_('clickCallback') != null) {
- // TODO(danvk): pass along more info about the points.
self.attr_('clickCallback')(event, self.lastx_, self.selPoints_);
}
if (self.attr_('pointClickCallback')) {
}
// Allow any click within two pixels of the dot.
- var radius = this.attr_('highlightCircleSize') + 2;
+ var radius = self.attr_('highlightCircleSize') + 2;
if (closestDistance <= 5 * 5) {
self.attr_('pointClickCallback')(event, self.selPoints_[closestIdx]);
}
}
var saveBg = '';
+ var num = 0;
g.updateOptions( {
annotationClickHandler: function(ann, point, dg, event) {
eventDiv.innerHTML += "click: " + nameAnnotation(ann) + "<br/>";
annotationMouseOutHandler: function(ann, point, dg, event) {
document.getElementById(nameAnnotation(ann)).style.fontWeight = 'normal';
ann.div.style.backgroundColor = saveBg;
+ },
+
+ pointClickCallback: function(event, p) {
+ // Check if the point is already annotated.
+ if (p.annotation) return;
+
+ // If not, add one.
+ var ann = {
+ series: p.name,
+ xval: p.xval,
+ shortText: num,
+ text: "Annotation #" + num
+ };
+ var anns = g.annotations();
+ anns.push(ann);
+ g.setAnnotations(anns);
+
+ num++;
}
});
</script>