var sat = this.attr_('colorSaturation') || 1.0;
var val = this.attr_('colorValue') || 0.5;
for (var i = 1; i <= num; i++) {
+ if (!this.visibility()[i-1]) continue;
var hue = (1.0*i/(1+num));
this.colors_.push( Dygraph.hsvToRGB(hue, sat, val) );
}
} else {
for (var i = 0; i < num; i++) {
+ if (!this.visibility()[i]) continue;
var colorStr = colors[i % colors.length];
this.colors_.push(colorStr);
}
--- /dev/null
+<html>
+ <head>
+ <title>color visibility</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-canvas.js"></script>
+ <script type="text/javascript" src="../dygraph.js"></script>
+ </head>
+ <body>
+ <p>The lines should maintain their colors as their visibility is toggled.</p>
+
+ <div id="blah"></div>
+ <p><b>Display: </b>
+ <input type=checkbox id=0 onClick="change(this)" checked>
+ <label for="0"> a</label>
+ <input type=checkbox id=1 onClick="change(this)" checked>
+ <label for="1"> b</label>
+ <input type=checkbox id=2 onClick="change(this)" checked>
+ <label for="2"> c</label>
+ </p>
+
+ <script type="text/javascript">
+ chart = new Dygraph(document.getElementById("blah"),
+ "X,a,b,c\n" +
+ "10,12345,23456,34567\n" +
+ "11,12345,20123,31345\n",
+ {
+ width: 640,
+ height: 480,
+ colors: ['#284785', '#EE1111', '#8AE234'],
+ visibility: [true, true, true]
+ });
+
+ function change(el) {
+ chart.setVisibility(el.id, el.checked);
+ }
+ </script>
+ </body>
+</html>