X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph.js;h=85ab1a9ea37ef8f7dbfa057dfce7ee255fe9e973;hb=44f29e932dcbe83c1bfaebb8735579392e27a5df;hp=c322882f19e7786aab533b6e089e7c707de1ec6f;hpb=4cac8c7a5228904d09da929b13375a4f5cda8563;p=dygraphs.git diff --git a/dygraph.js b/dygraph.js index c322882..85ab1a9 100644 --- a/dygraph.js +++ b/dygraph.js @@ -420,7 +420,7 @@ Dygraph.prototype.xAxisExtremes = function() { var left = this.rawData_[0][0]; var right = this.rawData_[this.rawData_.length - 1][0]; return [left, right]; -} +}; /** * Returns the currently-visible y-range for an axis. This can be affected by @@ -617,18 +617,8 @@ Dygraph.prototype.toPercentXCoord = function(x) { return null; } - var area = this.plotter_.area; var xRange = this.xAxisRange(); - - var pct; - // xRange[1] - x is unit distance from the right. - // xRange[1] - xRange[0] is the scale of the range. - // (xRange[1] - x / (xRange[1] - xRange[0]) is the % from the right. - // 1 - (that) is the % distance from the left. - pct = (xRange[1] - x) / (xRange[1] - xRange[0]); - // There's a way to optimize that, but I'm copying the y-coord function - // and am lazy. - return 1 - pct; + return (x - xRange[0]) / (xRange[1] - xRange[0]); } /** @@ -1041,9 +1031,8 @@ Dygraph.startPan = function(event, g, context) { context.initialLeftmostDate = xRange[0]; context.xUnitsPerPixel = context.dateRange / (g.plotter_.area.w - 1); - // TODO(konigsberg): do that clever "undefined" thing. - if (g.attr_("panFrame")) { - var maxXPixelsToDraw = g.width_ * g.attr_("panFrame"); + if (g.attr_("panEdgeFraction")) { + var maxXPixelsToDraw = g.width_ * g.attr_("panEdgeFraction"); var xExtremes = g.xAxisExtremes(); // I REALLY WANT TO CALL THIS xTremes! var boundedLeftX = g.toDomXCoord(xExtremes[0]) - maxXPixelsToDraw; @@ -1054,7 +1043,7 @@ Dygraph.startPan = function(event, g, context) { context.boundedDates = [boundedLeftDate, boundedRightDate]; var boundedValues = []; - var maxYPixelsToDraw = g.height_ * g.attr_("panFrame"); + var maxYPixelsToDraw = g.height_ * g.attr_("panEdgeFraction"); for (var i = 0; i < g.axes_.length; i++) { var axis = g.axes_[i]; @@ -1066,8 +1055,6 @@ Dygraph.startPan = function(event, g, context) { var boundedTopValue = g.toDataYCoord(boundedTopY); var boundedBottomValue = g.toDataYCoord(boundedBottomY); - console.log(yExtremes[0], yExtremes[1], boundedTopValue, boundedBottomValue); - // could reverse these, who knows? boundedValues[i] = [boundedTopValue, boundedBottomValue]; } context.boundedValues = boundedValues; @@ -1116,7 +1103,7 @@ Dygraph.movePan = function(event, g, context) { if (maxDate > context.boundedDates[1]) { // Adjust minDate, and recompute maxDate. minDate = minDate - (maxDate - context.boundedDates[1]); - var maxDate = minDate + context.dateRange; + maxDate = minDate + context.dateRange; } } @@ -1363,7 +1350,7 @@ Dygraph.prototype.createDragInterface_ = function() { px: 0, py: 0, - // Values for use with panFrame, which limit how far outside the + // Values for use with panEdgeFraction, which limit how far outside the // graph's data boundaries it can be panned. boundedDates: null, // [minDate, maxDate] boundedValues: null, // [[minValue, maxValue] ...] @@ -2730,6 +2717,20 @@ Dygraph.prototype.computeYAxisRanges_ = function(extremes) { seriesForAxis[idx].push(series); } + // If no series are defined or visible then fill in some reasonable defaults. + if (seriesForAxis.length == 0) { + var axis = this.axes_[0]; + axis.computedValueRange = [0, 1]; + var ret = + Dygraph.numericTicks(axis.computedValueRange[0], + axis.computedValueRange[1], + this, + axis); + axis.ticks = ret.ticks; + this.numYDigits_ = ret.numDigits; + return; + } + // Compute extreme values, a span and tick marks for each axis. for (var i = 0; i < this.axes_.length; i++) { var axis = this.axes_[i]; @@ -3338,6 +3339,11 @@ Dygraph.prototype.parseDataTable_ = function(data) { annotations.push(ann); } } + + // Strip out infinities, which give dygraphs problems later on. + for (var j = 0; j < row.length; j++) { + if (!isFinite(row[j])) row[j] = null; + } } else { for (var j = 0; j < cols - 1; j++) { row.push([ data.getValue(i, 1 + 2 * j), data.getValue(i, 2 + 2 * j) ]); @@ -3346,11 +3352,6 @@ Dygraph.prototype.parseDataTable_ = function(data) { if (ret.length > 0 && row[0] < ret[ret.length - 1][0]) { outOfOrder = true; } - - // Strip out infinities, which give dygraphs problems later on. - for (var j = 0; j < row.length; j++) { - if (!isFinite(row[j])) row[j] = null; - } ret.push(row); } @@ -4119,9 +4120,9 @@ Dygraph.OPTIONS_REFERENCE = // "type": "boolean", "description": "Only applies when Dygraphs is used as a GViz chart. Causes string columns following a data series to be interpreted as annotations on points in that series. This is the same format used by Google's AnnotatedTimeLine chart." }, - "panFrame": { + "panEdgeFraction": { "default": "null", - "labels": ["Axis Display?"], + "labels": ["Axis Display", "Interactive Elements"], "type": "float", "default": "null", "description": "A value representing the farthest a graph may be panned, in percent of the display. For example, a value of 0.1 means that the graph can only be panned 10% pased the edges of the displayed values. null means no bounds."