strokeWidth: 1.0,
- // TODO(danvk): default padding
+ axisTickSize: 3,
+ axisLabelFontSize: 14,
+ xAxisLabelWidth: 50,
+ yAxisLabelWidth: 50,
+ rightGap: 5,
showRoller: false,
xValueFormatter: Dygraph.dateString_,
this.wilsonInterval_ = attrs.wilsonInterval || true;
this.customBars_ = attrs.customBars || false;
+ // Clear the div. This ensure that, if multiple dygraphs are passed the same
+ // div, then only one will be drawn.
+ div.innerHTML = "";
+
// If the div isn't already sized then give it a default size.
if (div.style.width == '') {
div.style.width = Dygraph.DEFAULT_WIDTH + "px";
// TODO(danvk): why does the Renderer need its own set of options?
this.renderOptions_ = { colorScheme: this.colors_,
strokeColor: null,
- strokeWidth: this.attr_("strokeWidth"),
- axisLabelFontSize: 14,
axisLineWidth: Dygraph.AXIS_LINE_WIDTH };
MochiKit.Base.update(this.renderOptions_, this.attrs_);
MochiKit.Base.update(this.renderOptions_, this.user_attrs_);
appendChildNodes(enclosing, this.graphDiv);
// Create the canvas to store
+ // We need to subtract out some space for the x- and y-axis labels.
+ // For the x-axis:
+ // - remove from height: (axisTickSize + height of tick label)
+ // height of tick label == axisLabelFontSize?
+ // - remove from width: axisLabelWidth / 2 (maybe on both ends)
+ // For the y-axis:
+ // - remove axisLabelFontSize from the top
+ // - remove axisTickSize from the left
+
var canvas = MochiKit.DOM.CANVAS;
this.canvas_ = canvas( { style: { 'position': 'absolute' },
width: this.width_,
- height: this.height_});
+ height: this.height_
+ });
appendChildNodes(this.graphDiv, this.canvas_);
this.hidden_ = this.createPlotKitCanvas_(this.canvas_);
/**
* Creates the canvas containing the PlotKit graph. Only plotkit ever draws on
* this particular canvas. All Dygraph work is done on this.canvas_.
- * @param {Object} canvas The Dygraph canvas to over which to overlay the plot
+ * @param {Object} canvas The Dygraph canvas over which to overlay the plot
* @return {Object} The newly-created canvas
* @private
*/
"zIndex": 10,
"width": divWidth + "px",
"top": "0px",
- "left": this.width_ - divWidth + "px",
+ "left": (this.width_ - divWidth - 2) + "px",
"background": "white",
"textAlign": "left",
"overflow": "hidden"}};
* @private
*/
Dygraph.prototype.createRollInterface_ = function() {
- var padding = this.plotter_.options.padding;
var display = this.attr_('showRoller') ? "block" : "none";
var textAttr = { "type": "text",
"size": "2",
"value": this.rollPeriod_,
"style": { "position": "absolute",
"zIndex": 10,
- "top": (this.height_ - 25 - padding.bottom) + "px",
- "left": (padding.left+1) + "px",
+ "top": (this.plotter_.area.h - 25) + "px",
+ "left": (this.plotter_.area.x + 1) + "px",
"display": display }
};
var roller = MochiKit.DOM.INPUT(textAttr);
};
Dygraph.prototype.months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
Dygraph.prototype.quarters = ["Jan", "Apr", "Jul", "Oct"];
/**
this.attrs_.xValueFormatter = Dygraph.dateString_;
this.attrs_.xValueParser = Dygraph.dateParser;
this.attrs_.xTicker = Dygraph.dateTicker;
- } else if (indepType != 'number') {
+ } else if (indepType == 'number') {
this.attrs_.xValueFormatter = function(x) { return x; };
this.attrs_.xValueParser = function(x) { return parseFloat(x); };
this.attrs_.xTicker = Dygraph.numericTicks;
} else {
- this.error("only 'date' and 'number' types are supported for column 1" +
+ this.error("only 'date' and 'number' types are supported for column 1 " +
"of DataTable input (Got '" + indepType + "')");
return null;
}
var ret = [];
for (var i = 0; i < rows; i++) {
var row = [];
+ if (!data.getValue(i, 0)) continue;
if (indepType == 'date') {
row.push(data.getValue(i, 0).getTime());
} else {
row.push(data.getValue(i, 0));
}
+ var any_data = false;
for (var j = 1; j < cols; j++) {
row.push(data.getValue(i, j));
+ if (data.getValue(i, j)) any_data = true;
}
- ret.push(row);
+ if (any_data) ret.push(row);
}
return ret;
}