Dygraph.ANIMATION_STEPS = 12;
Dygraph.ANIMATION_DURATION = 200;
+// Label constants for the labelsKMB and labelsKMG2 options.
+// (i.e. '100000' -> '100K')
Dygraph.KMB_LABELS = [ 'K', 'M', 'B', 'T', 'Q' ];
Dygraph.KMG2_BIG_LABELS = [ 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' ];
Dygraph.KMG2_SMALL_LABELS = [ 'm', 'u', 'n', 'p', 'f', 'a', 'z', 'y' ];
var m_labels = [];
if (kmb) {
k = 1000;
- k_labels = [ "K", "M", "B", "T", "Q" ];
+ k_labels = Dygraph.KMB_LABELS;
}
if (kmg2) {
if (kmb) Dygraph.warn("Setting both labelsKMB and labelsKMG2. Pick one!");
k = 1024;
- k_labels = [ "k", "M", "G", "T", "P", "E", "Z", "Y" ];
- m_labels = [ "m", "u", "n", "p", "f", "a", "z", "y" ];
+ k_labels = Dygraph.KMG2_BIG_LABELS;
+ m_labels = Dygraph.KMG2_SMALL_LABELS;
}
var absx = Math.abs(x);
*/
Dygraph.prototype.xAxisExtremes = function() {
var pad = this.attr_('xRangePad') / this.plotter_.area.w;
- if (this.numRows() == 0) {
+ if (this.numRows() === 0) {
return [0 - pad, 1 + pad];
}
var left = this.rawData_[0][0];
var callback = this.attr_("highlightCallback");
if (callback && selectionChanged) {
- callback(event, this.lastx_, this.selPoints_, this.lastRow_, this.highlightSet_);
+ callback(event,
+ this.lastx_,
+ this.selPoints_,
+ this.lastRow_ + this.getLeftBoundary_(),
+ this.highlightSet_);
}
};
this.cascadeEvents_('willDrawChart', e);
this.plotter_.render();
this.cascadeEvents_('didDrawChart', e);
+ this.lastRow_ = -1; // because plugins/legend.js clears the legend
// TODO(danvk): is this a performance bottleneck when panning?
// The interaction canvas should already be empty in that situation.
* This fills in the valueRange and ticks fields in each entry of this.axes_.
*/
Dygraph.prototype.computeYAxisRanges_ = function(extremes) {
-
var isNullUndefinedOrNaN = function(num) {
return isNaN(parseFloat(num));
};
- var series;
var numAxes = this.attributes_.numAxes();
+ var ypadCompat, span, series, ypad;
// Compute extreme values, a span and tick marks for each axis.
for (var i = 0; i < numAxes; i++) {
if (minY == Infinity) minY = 0;
if (maxY == -Infinity) maxY = 1;
- var span = maxY - minY;
+ span = maxY - minY;
// special case: if we have no sense of scale, center on the sole value.
if (span === 0) {
if (maxY !== 0) {
// - new-style (yRangePad set by the user):
// always add the specified Y padding.
//
- var ypadCompat = true;
- var ypad = 0.1; // add 10%
+ ypadCompat = true;
+ ypad = 0.1; // add 10%
if (this.attr_('yRangePad') !== null) {
ypadCompat = false;
// Convert pixel padding to ratio
y0 *= logpad;
y1 /= logpad;
} else {
- var span = y1 - y0;
+ span = y1 - y0;
y0 -= span * ypad;
y1 += span * ypad;
}