From: Dan Vanderkam Date: Tue, 23 Jul 2013 03:19:24 +0000 (-0400) Subject: can draw and interact! X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=0fde68cf8e0799c9510cb9c6b1c4822a626025ef;p=dygraphs.git can draw and interact! --- diff --git a/dygraph-canvas.js b/dygraph-canvas.js index d2d95c7..91d78c7 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -428,7 +428,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function(opt_seriesName, opt_ /** @type{!Array.} */ var plotters; - if (!Dygraph.isArrayLike(plotters)) { + if (!Dygraph.isArrayLike(plotter_attr)) { plotters = [plotters]; } else { plotters = /** @type {!Array.} */(plotter_attr); @@ -471,7 +471,6 @@ DygraphCanvasRenderer.prototype._renderLineChart = function(opt_seriesName, opt_ ctx.save(); ctx.strokeStyle = color; ctx.lineWidth = strokeWidth; - // TODO(danvk): add an @typedef for this Object. p({ points: points, setName: setName, @@ -493,6 +492,7 @@ DygraphCanvasRenderer.prototype._renderLineChart = function(opt_seriesName, opt_ /** * Plotter which draws the central lines for a series. + * @param {DygraphPlotterArguments} e Plotter inputs. * @private */ linePlotter_ = function(e) { @@ -535,6 +535,7 @@ linePlotter_ = function(e) { * Draws the shaded error bars/confidence intervals for each series. * This happens before the center lines are drawn, since the center lines * need to be drawn on top of the error bars for all series. + * @param {DygraphPlotterArguments} e Plotter inputs. * @private */ errorPlotter_ = function(e) { @@ -619,6 +620,7 @@ errorPlotter_ = function(e) { * simultaneously. So this plotter plots all the points on the first series * it's asked to draw, then ignores all the other series. * + * @param {DygraphPlotterArguments} e Plotter inputs. * @private */ fillPlotter_ = function(e) { diff --git a/dygraph-externs.js b/dygraph-externs.js index fa0d949..08af6f5 100644 --- a/dygraph-externs.js +++ b/dygraph-externs.js @@ -101,9 +101,28 @@ var DygraphRect; */ var DygraphAxisType; + +/** + * @typedef {{ + * dygraph: !Dygraph, + * points: Array, + * setName: string, + * drawingContext: !CanvasRenderingContext2D, + * color: string, + * strokeWidth: number, + * axis: Object, + * plotArea: DygraphRect, + * seriesIndex: number, + * seriesCount: number, + * singleSeriesName: (string|undefined), + * allSeriesPoints: Array + * }} + */ +var DygraphPlotterArguments; + /** * TODO(danvk): be more specific than "Object". - * @typedef {function(Object)} + * @typedef {function(DygraphPlotterArguments)} */ var DygraphPlotterType; diff --git a/dygraph-options.js b/dygraph-options.js index 70b5f75..4ef1153 100644 --- a/dygraph-options.js +++ b/dygraph-options.js @@ -298,7 +298,7 @@ DygraphOptions.prototype.getForAxis = function(name, axis) { } // Default axis options third. - var defaultAxisOptions = Dygraph.DEFAULT_ATTRS.axes[axisString]; + var defaultAxisOptions = Dygraph.DEFAULT_ATTRS['axes'][axisString]; if (defaultAxisOptions.hasOwnProperty(name)) { return defaultAxisOptions[name]; } @@ -327,12 +327,12 @@ DygraphOptions.prototype.getForSeries = function(name, series) { } var seriesObj = this.series_[series]; - var seriesOptions = seriesObj["options"]; + var seriesOptions = seriesObj.options; if (seriesOptions.hasOwnProperty(name)) { return seriesOptions[name]; } - return this.getForAxis(name, seriesObj["yAxis"]); + return this.getForAxis(name, seriesObj.yAxis); }; /** diff --git a/dygraph.js b/dygraph.js index 452143d..e2ec821 100644 --- a/dygraph.js +++ b/dygraph.js @@ -651,7 +651,7 @@ Dygraph.prototype.getOptionForAxis = function(name, axis) { Dygraph.prototype.optionsViewForAxis_ = function(axis) { var self = this; return function(opt) { - var axis_opts = self.user_attrs_.axes; + var axis_opts = self.user_attrs_['axes']; if (axis_opts && axis_opts[axis] && axis_opts[axis].hasOwnProperty(opt)) { return axis_opts[axis][opt]; } @@ -661,7 +661,7 @@ Dygraph.prototype.optionsViewForAxis_ = function(axis) { return self.user_attrs_[opt]; } - axis_opts = self.attrs_.axes; + axis_opts = self.attrs_['axes']; if (axis_opts && axis_opts[axis] && axis_opts[axis].hasOwnProperty(opt)) { return axis_opts[axis][opt]; } @@ -2666,10 +2666,10 @@ Dygraph.prototype.computeYAxes_ = function() { v = opts("valueRange"); if (v) this.axes_[axis].valueRange = v; } else { // To keep old behavior - var axes = this.user_attrs_.axes; - if (axes && axes.y2) { - v = axes.y2.valueRange; - if (v) this.axes_[axis].valueRange = v; + var axes = this.user_attrs_['axes']; + if (axes && axes['y2']) { + v = axes['y2']['valueRange']; + if (v) this.axes_[axis]['valueRange'] = v; } } } @@ -3095,18 +3095,18 @@ Dygraph.prototype.detectTypeFromString_ = function(str) { Dygraph.prototype.setXAxisOptions_ = function(isDate) { if (isDate) { - this.attrs_.xValueParser = Dygraph.dateParser; - this.attrs_.axes.x.valueFormatter = Dygraph.dateString_; - this.attrs_.axes.x.ticker = Dygraph.dateTicker; - this.attrs_.axes.x.axisLabelFormatter = dateAxisFormatter_; + this.attrs_['xValueParser'] = Dygraph.dateParser; + this.attrs_['axes']['x']['valueFormatter'] = Dygraph.dateString_; + this.attrs_['axes']['x']['ticker'] = Dygraph.dateTicker; + this.attrs_['axes']['x']['axisLabelFormatter'] = dateAxisFormatter_; } else { /** @private (shut up, jsdoc!) */ - this.attrs_.xValueParser = function(x) { return parseFloat(x); }; + this.attrs_['xValueParser'] = function(x) { return parseFloat(x); }; // TODO(danvk): use numberValueFormatter_ here? /** @private (shut up, jsdoc!) */ - this.attrs_.axes.x.valueFormatter = function(x) { return x; }; - this.attrs_.axes.x.ticker = Dygraph.numericLinearTicks; - this.attrs_.axes.x.axisLabelFormatter = this.attrs_.axes.x.valueFormatter; + this.attrs_['axes']['x']['valueFormatter'] = function(x) { return x; }; + this.attrs_['axes']['x']['ticker'] = Dygraph.numericLinearTicks; + this.attrs_['axes']['x']['axisLabelFormatter'] = this.attrs_['axes']['x']['valueFormatter']; } }; diff --git a/generate-combined.sh b/generate-combined.sh index 21ebd3c..2c09487 100755 --- a/generate-combined.sh +++ b/generate-combined.sh @@ -36,7 +36,7 @@ Copyright () { CatMinified () { Copyright CatSources \ - | java -jar ../../closure-compiler-read-only/build/compiler.jar --js ../../closure-library-read-only/closure/goog/base.js --js - --js dygraph-exports.js --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --externs dygraph-externs.js --externs gviz-api.js --output_wrapper='(function() {%output%})();' + | java -jar ../../closure-compiler-read-only/build/compiler.jar --js ../../closure-library-read-only/closure/goog/base.js --js - --js dygraph-exports.js --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --externs dygraph-externs.js --externs gviz-api.js --formatting PRETTY_PRINT --output_wrapper='(function() {%output%})();' #| uglifyjs - -c 'warnings=false' -m # | java -jar yuicompressor-2.4.2.jar --type js