"default": "onmouseover",
"labels": ["Legend"],
"type": "string",
- "description": "When to display the legend. By default, it only appears when a user mouses over the chart. Set it to \"always\" to always display a legend of some sort."
- },
- "legendFollow": {
- "default": "false",
- "labels": ["Legend"],
- "type": "boolean",
- "description": "Legend follows highlighted points"
+ "description": "When to display the legend. By default, it only appears when a user mouses over the chart. Set it to \"always\" to always display a legend of some sort. When set to \"follow\", legend follows highlighted points."
},
"labelsShowZeroValues": {
"default": "true",
var xValue = e.selectedX;
var points = e.selectedPoints;
- if (e.dygraph.getOption("legendFollow")) {
+ if (e.dygraph.getOption("legend") === "follow") {
// create floating legend div
var area = e.dygraph.plotter_.area;
var labelsDivWidth = e.dygraph.getOption("labelsDivWidth");
e.dygraph.graphDiv.appendChild(this.legend_div_);
this.legend_div_.style.left = yAxisLabelWidth + leftLegend + "px";
this.legend_div_.style.top = topLegend + "px";
+ this.legend_div_.style.display = "block";
}
var html = generateLegendHTML(e.dygraph, xValue, points, this.one_em_width_);
legend.prototype.deselect = function(e) {
- if(e.dygraph.getOption("legendFollow")) {
- // return legend to the default non-floating position
- this.predraw(e);
+ if (e.dygraph.getOption("legend") === "follow") {
+ this.legend_div_.style.display = "none";
}
// Have to do this every time, since styles might have changed.