* dygraphs.
*/
-var DygraphLayout = (function() {
-
/*global Dygraph:false */
"use strict";
+import * as utils from './dygraph-utils';
+
/**
* Creates a new DygraphLayout object.
*
"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);
}
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++) {
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 +
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;
}
*/
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);
};
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;
- 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)) {
- this.xticks.push([pos, label]);
+ this.xticks.push({pos, label, has_tick});
}
}
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)) {
- this.yticks.push([i, pos, label]);
+ this.yticks.push({axis: i, pos, label, has_tick});
}
}
}
this.setPointsOffsets = [];
};
-return DygraphLayout;
-
-})();
+export default DygraphLayout;