projects
/
dygraphs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9d6c91a
)
better error with non-existent labelsDiv
author
Dan Vanderkam
<dan@dygraphs.com>
Sun, 24 Apr 2011 17:50:11 +0000
(13:50 -0400)
committer
Dan Vanderkam
<dan@dygraphs.com>
Sun, 24 Apr 2011 17:50:11 +0000
(13:50 -0400)
dygraph.js
patch
|
blob
|
blame
|
history
diff --git
a/dygraph.js
b/dygraph.js
index
d7dc8e5
..
349f62c
100644
(file)
--- a/
dygraph.js
+++ b/
dygraph.js
@@
-1652,7
+1652,7
@@
Dygraph.prototype.generateLegendHTML_ = function(x, sel_points) {
if (sepLines) html += "<br/>";
var c = this.plotter_.colors[pt.name];
if (sepLines) html += "<br/>";
var c = this.plotter_.colors[pt.name];
- var yval = fmtFunc(pt.yval,
displayDigit
s);
+ var yval = fmtFunc(pt.yval,
thi
s);
// TODO(danvk): use a template string here and make it an attribute.
html += " <b><span style='color: " + c + ";'>"
+ pt.name + "</span></b>:"
// TODO(danvk): use a template string here and make it an attribute.
html += " <b><span style='color: " + c + ";'>"
+ pt.name + "</span></b>:"
@@
-1661,6
+1661,19
@@
Dygraph.prototype.generateLegendHTML_ = function(x, sel_points) {
return html;
};
return html;
};
+Dygraph.prototype.setLegendHTML_ = function(x, sel_points) {
+ var html = this.generateLegendHTML_(x, sel_points);
+ var labelsDiv = this.attr_("labelsDiv");
+ if (labelsDiv !== null) {
+ labelsDiv.innerHTML = html;
+ } else {
+ if (typeof(this.shown_legend_error_) == 'undefined') {
+ this.error('labelsDiv is set to something nonexistent; legend will not be shown.');
+ this.shown_legend_error_ = true;
+ }
+ }
+};
+
/**
* Draw dots over the selectied points in the data series. This function
* takes care of cleanup of previously-drawn dots.
/**
* Draw dots over the selectied points in the data series. This function
* takes care of cleanup of previously-drawn dots.
@@
-1685,8
+1698,7
@@
Dygraph.prototype.updateSelection_ = function() {
if (this.selPoints_.length > 0) {
// Set the status message to indicate the selected point(s)
if (this.attr_('showLabelsOnHighlight')) {
if (this.selPoints_.length > 0) {
// Set the status message to indicate the selected point(s)
if (this.attr_('showLabelsOnHighlight')) {
- var html = this.generateLegendHTML_(this.lastx_, this.selPoints_);
- this.attr_("labelsDiv").innerHTML = html;
+ this.setLegendHTML_(this.lastx_, this.selPoints_);
}
// Draw colored circles over the center of each selected point
}
// Draw colored circles over the center of each selected point
@@
-1770,7
+1782,7
@@
Dygraph.prototype.clearSelection = function() {
// Get rid of the overlay data
var ctx = this.canvas_.getContext("2d");
ctx.clearRect(0, 0, this.width_, this.height_);
// Get rid of the overlay data
var ctx = this.canvas_.getContext("2d");
ctx.clearRect(0, 0, this.width_, this.height_);
- this.
attr_('labelsDiv').innerHTML = this.generate
LegendHTML_();
+ this.
set
LegendHTML_();
this.selPoints_ = [];
this.lastx_ = -1;
}
this.selPoints_ = [];
this.lastx_ = -1;
}
@@
-2581,7
+2593,7
@@
Dygraph.prototype.drawGraph_ = function() {
if (is_initial_draw) {
// Generate a static legend before any particular point is selected.
if (is_initial_draw) {
// Generate a static legend before any particular point is selected.
- this.
attr_('labelsDiv').innerHTML = this.generate
LegendHTML_();
+ this.
set
LegendHTML_();
} else {
if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) {
this.lastx_ = this.selPoints_[0].xval;
} else {
if (typeof(this.selPoints_) !== 'undefined' && this.selPoints_.length) {
this.lastx_ = this.selPoints_[0].xval;