projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement tick.label_v.
[dygraphs.git]
/
src
/
dygraph-layout.js
diff --git
a/src/dygraph-layout.js
b/src/dygraph-layout.js
index
ef1df91
..
c32a9e5
100644
(file)
--- a/
src/dygraph-layout.js
+++ b/
src/dygraph-layout.js
@@
-9,11
+9,11
@@
* dygraphs.
*/
* dygraphs.
*/
-var DygraphLayout = (function() {
-
/*global Dygraph:false */
"use strict";
/*global Dygraph:false */
"use strict";
+import * as utils from './dygraph-utils';
+
/**
* Creates a new DygraphLayout object.
*
/**
* Creates a new DygraphLayout object.
*
@@
-160,7
+160,7
@@
DygraphLayout.prototype.setAnnotations = function(ann) {
"annotation.icon property");
return;
}
"annotation.icon property");
return;
}
-
Dygraph
.update(a, ann[i]);
+
utils
.update(a, ann[i]);
if (!a.xval) a.xval = parse(a.x);
this.annotations.push(a);
}
if (!a.xval) a.xval = parse(a.x);
this.annotations.push(a);
}
@@
-191,7
+191,7
@@
DygraphLayout.prototype._evaluateLimits = function() {
this._xAxis.scale = (xrange !== 0 ? 1 / xrange : 1.0);
if (this.dygraph_.getOptionForAxis("logscale", 'x')) {
this._xAxis.scale = (xrange !== 0 ? 1 / xrange : 1.0);
if (this.dygraph_.getOptionForAxis("logscale", 'x')) {
- this._xAxis.xlogrange =
Dygraph.log10(this._xAxis.maxval) - Dygraph
.log10(this._xAxis.minval);
+ this._xAxis.xlogrange =
utils.log10(this._xAxis.maxval) - utils
.log10(this._xAxis.minval);
this._xAxis.xlogscale = (this._xAxis.xlogrange !== 0 ? 1.0 / this._xAxis.xlogrange : 1.0);
}
for (var i = 0; i < this.yAxes_.length; i++) {
this._xAxis.xlogscale = (this._xAxis.xlogrange !== 0 ? 1.0 / this._xAxis.xlogrange : 1.0);
}
for (var i = 0; i < this.yAxes_.length; i++) {
@@
-202,7
+202,7
@@
DygraphLayout.prototype._evaluateLimits = function() {
axis.yscale = (axis.yrange !== 0 ? 1.0 / axis.yrange : 1.0);
if (this.dygraph_.getOption("logscale")) {
axis.yscale = (axis.yrange !== 0 ? 1.0 / axis.yrange : 1.0);
if (this.dygraph_.getOption("logscale")) {
- axis.ylogrange =
Dygraph.log10(axis.maxyval) - Dygraph
.log10(axis.minyval);
+ axis.ylogrange =
utils.log10(axis.maxyval) - utils
.log10(axis.minyval);
axis.ylogscale = (axis.ylogrange !== 0 ? 1.0 / axis.ylogrange : 1.0);
if (!isFinite(axis.ylogrange) || isNaN(axis.ylogrange)) {
console.error('axis ' + i + ' of graph at ' + axis.g +
axis.ylogscale = (axis.ylogrange !== 0 ? 1.0 / axis.ylogrange : 1.0);
if (!isFinite(axis.ylogrange) || isNaN(axis.ylogrange)) {
console.error('axis ' + i + ' of graph at ' + axis.g +
@@
-215,7
+215,7
@@
DygraphLayout.prototype._evaluateLimits = function() {
DygraphLayout.calcXNormal_ = function(value, xAxis, logscale) {
if (logscale) {
DygraphLayout.calcXNormal_ = function(value, xAxis, logscale) {
if (logscale) {
- return ((
Dygraph.log10(value) - Dygraph
.log10(xAxis.minval)) * xAxis.xlogscale);
+ return ((
utils.log10(value) - utils
.log10(xAxis.minval)) * xAxis.xlogscale);
} else {
return (value - xAxis.minval) * xAxis.scale;
}
} else {
return (value - xAxis.minval) * xAxis.scale;
}
@@
-229,7
+229,7
@@
DygraphLayout.calcXNormal_ = function(value, xAxis, logscale) {
*/
DygraphLayout.calcYNormal_ = function(axis, value, logscale) {
if (logscale) {
*/
DygraphLayout.calcYNormal_ = function(axis, value, logscale) {
if (logscale) {
- var x = 1.0 - ((
Dygraph.log10(value) - Dygraph
.log10(axis.minyval)) * axis.ylogscale);
+ var x = 1.0 - ((
utils.log10(value) - utils
.log10(axis.minyval)) * axis.ylogscale);
return isFinite(x) ? x : NaN; // shim for v8 issue; see pull request 276
} else {
return 1.0 - ((value - axis.minyval) * axis.yscale);
return isFinite(x) ? x : NaN; // shim for v8 issue; see pull request 276
} else {
return 1.0 - ((value - axis.minyval) * axis.yscale);
@@
-276,14
+276,16
@@
DygraphLayout.prototype._evaluateLineCharts = function() {
};
DygraphLayout.prototype._evaluateLineTicks = function() {
};
DygraphLayout.prototype._evaluateLineTicks = function() {
- var i, tick, label, pos;
+ var i, tick, label, pos
, v, has_tick
;
this.xticks = [];
for (i = 0; i < this.xTicks_.length; i++) {
tick = this.xTicks_[i];
label = tick.label;
this.xticks = [];
for (i = 0; i < this.xTicks_.length; i++) {
tick = this.xTicks_[i];
label = tick.label;
- pos = this.dygraph_.toPercentXCoord(tick.v);
+ has_tick = !('label_v' in tick);
+ v = has_tick ? tick.v : tick.label_v;
+ pos = this.dygraph_.toPercentXCoord(v);
if ((pos >= 0.0) && (pos < 1.0)) {
if ((pos >= 0.0) && (pos < 1.0)) {
- this.xticks.push(
[pos, label]
);
+ this.xticks.push(
{pos, label, has_tick}
);
}
}
}
}
@@
-293,9
+295,11
@@
DygraphLayout.prototype._evaluateLineTicks = function() {
for (var j = 0; j < axis.ticks.length; j++) {
tick = axis.ticks[j];
label = tick.label;
for (var j = 0; j < axis.ticks.length; j++) {
tick = axis.ticks[j];
label = tick.label;
- pos = this.dygraph_.toPercentYCoord(tick.v, i);
+ has_tick = !('label_v' in tick);
+ v = has_tick ? tick.v : tick.label_v;
+ pos = this.dygraph_.toPercentYCoord(v, i);
if ((pos > 0.0) && (pos <= 1.0)) {
if ((pos > 0.0) && (pos <= 1.0)) {
- this.yticks.push(
[i, pos, label]
);
+ this.yticks.push(
{axis: i, pos, label, has_tick}
);
}
}
}
}
}
}
@@
-346,6
+350,4
@@
DygraphLayout.prototype.removeAllDatasets = function() {
this.setPointsOffsets = [];
};
this.setPointsOffsets = [];
};
-return DygraphLayout;
-
-})();
+export default DygraphLayout;