From 0e23cfc6960a43d8d03a86be2236f8ede092b602 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Mon, 9 May 2011 08:58:31 -0700 Subject: [PATCH] hack more renderer options out --- dygraph-canvas.js | 9 +++++---- dygraph.js | 20 ++------------------ 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index c2b2e24..9ac88be 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -330,6 +330,7 @@ DygraphCanvasRenderer.prototype.attr_ = function(x) { // Compute the box which the chart should be drawn in. This is the canvas's // box, less space needed for axis and chart labels. +// TODO(danvk): this belongs in DygraphLayout. DygraphCanvasRenderer.prototype.computeArea_ = function() { var area = { // TODO(danvk): per-axis setting. @@ -536,7 +537,7 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { var y = this.area.y + tick[1] * this.area.h; context.beginPath(); context.moveTo(halfUp(x), halfDown(y)); - context.lineTo(halfUp(x - sgn * this.attr_('axisTickSize'), halfDown(y)); + context.lineTo(halfUp(x - sgn * this.attr_('axisTickSize')), halfDown(y)); context.closePath(); context.stroke(); @@ -836,8 +837,7 @@ DygraphCanvasRenderer.prototype._renderAnnotations = function() { DygraphCanvasRenderer.prototype._renderLineChart = function() { // TODO(danvk): use this.attr_ for many of these. var context = this.elementContext; - var colorCount = this.options.colorScheme.length; - var colorScheme = this.options.colorScheme; + var colorScheme = this.attr_('colors'); var fillAlpha = this.attr_('fillAlpha'); var errorBars = this.attr_("errorBars"); var fillGraph = this.attr_("fillGraph"); @@ -852,9 +852,10 @@ DygraphCanvasRenderer.prototype._renderLineChart = function() { } var setCount = setNames.length; + // TODO(danvk): Move this mapping into Dygraph and get it out of here. this.colors = {} for (var i = 0; i < setCount; i++) { - this.colors[setNames[i]] = colorScheme[i % colorCount]; + this.colors[setNames[i]] = colorScheme[i % colorScheme.length]; } // Update Points diff --git a/dygraph.js b/dygraph.js index 794fecf..ac1bc03 100644 --- a/dygraph.js +++ b/dygraph.js @@ -85,7 +85,6 @@ Dygraph.toString = function() { Dygraph.DEFAULT_ROLL_PERIOD = 1; Dygraph.DEFAULT_WIDTH = 480; Dygraph.DEFAULT_HEIGHT = 320; -Dygraph.AXIS_LINE_WIDTH = 0.3; Dygraph.LOG_SCALE = 10; Dygraph.LN_TEN = Math.log(Dygraph.LOG_SCALE); @@ -158,7 +157,7 @@ Dygraph.DEFAULT_ATTRS = { drawXAxis: true, drawYAxis: true, axisLineColor: "black", - "axisLineWidth": 0.5, + "axisLineWidth": 0.3, "axisLabelColor": "black", "axisLabelFont": "Arial", // TODO(danvk): is this implemented? "axisLabelWidth": 50, @@ -772,13 +771,6 @@ Dygraph.prototype.createInterface_ = function() { // Create the grapher this.layout_ = new DygraphLayout(this); - // TODO(danvk): why does the Renderer need its own set of options? - this.renderOptions_ = { colorScheme: this.colors_, - strokeColor: null, - axisLineWidth: Dygraph.AXIS_LINE_WIDTH }; - Dygraph.update(this.renderOptions_, this.attrs_); - Dygraph.update(this.renderOptions_, this.user_attrs_); - this.createStatusMessage_(); this.createDragInterface_(); }; @@ -883,8 +875,6 @@ Dygraph.hsvToRGB = function (hue, saturation, value) { * @private */ Dygraph.prototype.setColors_ = function() { - // TODO(danvk): compute this directly into this.attrs_['colorScheme'] and do - // away with this.renderOptions_. var num = this.attr_("labels").length - 1; this.colors_ = []; var colors = this.attr_('colors'); @@ -906,10 +896,6 @@ Dygraph.prototype.setColors_ = function() { this.colors_.push(colorStr); } } - - // TODO(danvk): update this w/r/t/ the new options system. - this.renderOptions_.colorScheme = this.colors_; - Dygraph.update(this.plotter_.options, this.renderOptions_); }; /** @@ -2654,8 +2640,7 @@ Dygraph.prototype.predraw_ = function() { this.plotter_ = new DygraphCanvasRenderer(this, this.hidden_, this.hidden_ctx_, - this.layout_, - this.renderOptions_); + this.layout_); // The roller sits in the bottom left corner of the chart. We don't know where // this will be until the options are available, so it's positioned here. @@ -3771,7 +3756,6 @@ Dygraph.prototype.updateOptions = function(attrs) { // highlightCircleSize Dygraph.update(this.user_attrs_, attrs); - Dygraph.update(this.renderOptions_, attrs); this.labelsFromCSV_ = (this.attr_("labels") == null); -- 2.7.4