DateGraph.DEFAULT_STROKE_WIDTH = 1.0;
DateGraph.AXIS_LINE_WIDTH = 0.3;
+// Default attribute values.
+DateGraph.DEFAULT_ATTRS = {
+ pixelsPerXLabel: 60,
+ labelsDivWidth: 250,
+ labelsDivStyles: {
+ // TODO(danvk): move defaults from createStatusMessage_ here.
+ }
+
+ // TODO(danvk): default padding
+};
+
/**
* Initializes the DateGraph. This creates a new DIV and constructs the PlotKit
* and interaction <canvas> inside of it. See the constructor for details
this.sigma_ = attrs.sigma || 2.0;
this.wilsonInterval_ = attrs.wilsonInterval || true;
this.customBars_ = attrs.customBars || false;
- this.attrs_ = attrs;
+
+ this.attrs_ = DateGraph.DEFAULT_ATTRS;
+ MochiKit.Base.update(this.attrs_, attrs);
if (typeof this.attrs_.pixelsPerXLabel == 'undefined') {
this.attrs_.pixelsPerXLabel = 60;
*/
DateGraph.prototype.createStatusMessage_ = function(){
if (!this.labelsDiv_) {
- var divWidth = 250;
+ var divWidth = this.attrs_.labelsDivWidth;
var messagestyle = { "style": {
"position": "absolute",
"fontSize": "14px",
"background": "white",
"textAlign": "left",
"overflow": "hidden"}};
+ MochiKit.Base.update(messagestyle["style"], this.attrs_.labelsDivStyles);
this.labelsDiv_ = MochiKit.DOM.DIV(messagestyle);
MochiKit.DOM.appendChildNodes(this.graphDiv, this.labelsDiv_);
}
--- /dev/null
+<html>
+ <head>
+ <title>Label styles</title>
+ <!--[if IE]>
+ <script type="text/javascript" src="excanvas.js"></script>
+ <![endif]-->
+ <script type="text/javascript" src="../dygraph-combined.js"></script>
+ <script type="text/javascript" src="../dygraph.js"></script>
+ <script type="text/javascript" src="data.js"></script>
+ </head>
+ <body>
+ <p>Labels are transparent and repositioned:</p>
+ <div id="g14" style="width:600px; height:300px;"></div>
+
+ <script type="text/javascript">
+ g14 = new DateGraph(
+ document.getElementById("g14"),
+ NoisyData, null, {
+ rollPeriod: 14,
+ errorBars: true,
+ labelsDivWidth: 160,
+ labelsDivStyles: {
+ 'background-color': 'transparent',
+ 'top': '10px'
+ },
+ padding: {
+ left: 40,
+ top: 0,
+ right: 10,
+ bottom: 10
+ }
+ }
+ );
+ </script>
+ </body>
+</html>