projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #178 from kberg/tests
[dygraphs.git]
/
dygraph.js
diff --git
a/dygraph.js
b/dygraph.js
index
ae61842
..
42e87c8
100644
(file)
--- a/
dygraph.js
+++ b/
dygraph.js
@@
-355,6
+355,10
@@
Dygraph.prototype.__init__ = function(div, file, attrs) {
attrs = Dygraph.mapLegacyOptions_(attrs);
attrs = Dygraph.mapLegacyOptions_(attrs);
+ if (typeof(div) == 'string') {
+ div = document.getElementById(div);
+ }
+
if (!div) {
Dygraph.error("Constructing dygraph with a non-existent div!");
return;
if (!div) {
Dygraph.error("Constructing dygraph with a non-existent div!");
return;
@@
-603,13
+607,12
@@
Dygraph.prototype.attr_ = function(name, seriesName) {
}
var computedValue = seriesName ? this.attributes_.findForSeries(name, seriesName) : this.attributes_.find(name);
}
var computedValue = seriesName ? this.attributes_.findForSeries(name, seriesName) : this.attributes_.find(name);
-
if (ret !== computedValue) {
console.log("Mismatch", name, seriesName, ret, computedValue);
if (ret !== computedValue) {
console.log("Mismatch", name, seriesName, ret, computedValue);
- } else {
- console.log("Match", name, seriesName, ret, computedValue);
}
}
- return computedValue;
+
+ var USE_NEW_VALUE = true;
+ return USE_NEW_VALUE ? computedValue : ret;
};
/**
};
/**
@@
-1688,7
+1691,7
@@
Dygraph.prototype.findClosestPoint = function(domX, domY) {
var minDist = Infinity;
var idx = -1;
var dist, dx, dy, point, closestPoint, closestSeries;
var minDist = Infinity;
var idx = -1;
var dist, dx, dy, point, closestPoint, closestSeries;
- for (
var setIdx = 0; setIdx < this.layout_.datasets.length; ++setIdx
) {
+ for (
var setIdx = this.layout_.datasets.length - 1 ; setIdx >= 0 ; --setIdx
) {
var points = this.layout_.points[setIdx];
for (var i = 0; i < points.length; ++i) {
var point = points[i];
var points = this.layout_.points[setIdx];
for (var i = 0; i < points.length; ++i) {
var point = points[i];
@@
-1789,7
+1792,7
@@
Dygraph.prototype.mouseMove_ = function(event) {
var highlightSeriesOpts = this.attr_("highlightSeriesOpts");
var selectionChanged = false;
var highlightSeriesOpts = this.attr_("highlightSeriesOpts");
var selectionChanged = false;
- if (highlightSeriesOpts && !this.
lockedSet_
) {
+ if (highlightSeriesOpts && !this.
isSeriesLocked()
) {
var closest;
if (this.attr_("stackedGraph")) {
closest = this.findStackedPoint(canvasx, canvasy);
var closest;
if (this.attr_("stackedGraph")) {
closest = this.findStackedPoint(canvasx, canvasy);
@@
-2082,6
+2085,14
@@
Dygraph.prototype.getHighlightSeries = function() {
};
/**
};
/**
+ * Returns true if the currently-highlighted series was locked
+ * via setSelection(..., seriesName, true).
+ */
+Dygraph.prototype.isSeriesLocked = function() {
+ return this.lockedSet_;
+};
+
+/**
* Fires when there's data available to be graphed.
* @param {String} data Raw CSV data to be plotted
* @private
* Fires when there's data available to be graphed.
* @param {String} data Raw CSV data to be plotted
* @private
@@
-3108,8
+3119,9
@@
Dygraph.prototype.parseArray_ = function(data) {
"in the options parameter");
this.attrs_.labels = [ "X" ];
for (i = 1; i < data[0].length; i++) {
"in the options parameter");
this.attrs_.labels = [ "X" ];
for (i = 1; i < data[0].length; i++) {
- this.attrs_.labels.push("Y" + i);
+ this.attrs_.labels.push("Y" + i);
// Not user_attrs_.
}
}
+ this.attributes_.reparseSeries();
} else {
var num_labels = this.attr_("labels");
if (num_labels.length != data[0].length) {
} else {
var num_labels = this.attr_("labels");
if (num_labels.length != data[0].length) {