var seriesName = this.attr_("labels")[i];
var connectSeparatedPoints = this.attr_('connectSeparatedPoints', i);
+ var logScale = this.attr_('logscale', i);
var series = [];
for (var j = 0; j < data.length; j++) {
- if (data[j][i] != null || !connectSeparatedPoints) {
- var date = data[j][0];
- series.push([date, data[j][i]]);
+ var date = data[j][0];
+ var point = data[j][i];
+ if (logScale) {
+ // On the log scale, points less than zero do not exist.
+ // This will create a gap in the chart. Note that this ignores
+ // connectSeparatedPoints.
+ if (point < 0) {
+ point = null;
+ }
+ series.push([date, point]);
+ } else {
+ if (point != null || !connectSeparatedPoints) {
+ series.push([date, point]);
+ }
}
}
--- /dev/null
+<html>
+ <head>
+ <title>log scale</title>
+ <!--[if IE]>
+ <script type="text/javascript" src="../excanvas.js"></script>
+ <![endif]-->
+ <script type="text/javascript" src="../strftime/strftime-min.js"></script>
+ <script type="text/javascript" src="../rgbcolor/rgbcolor.js"></script>
+ <script type="text/javascript" src="../dygraph-canvas.js"></script>
+ <script type="text/javascript" src="../dygraph.js"></script>
+ </head>
+
+ <body>
+ <h1>Log scale demo - work in progress</h1>
+ <div id="div_g" style="width:600px; height:300px;"></div>
+
+ <input type="button" value="log scale" onclick="logScale()">
+ <input type="button" value="linear scale" onclick="linearScale()">
+ <script type="text/javascript">
+ function Data() {
+ return "Date,A\n" +
+ "20101201,5\n"+
+ "20101202,10\n"+
+ "20101203,-1\n"+
+ "20101204,250\n"+
+ "20101205,1000\n"+
+ "20101206,30\n"+
+ "20101207,80\n"+
+ "20101208,100\n"+
+ "20101209,500\n"+
+ "";
+ }
+ var g = new Dygraph(document.getElementById("div_g"),
+ Data, { logscale : true});
+
+ function logScale() {
+ g.updateOptions({ logscale : true });
+ }
+ function linearScale() {
+ g.updateOptions({ logscale : false });
+ }
+ </script>
+
+ </body>
+</html>