| 1 | /*global Gallery,Dygraph,data,$ */ |
| 2 | /*jshint unused:false */ |
| 3 | Gallery.register( |
| 4 | 'color-visibility', |
| 5 | { |
| 6 | name: "Color visibility", |
| 7 | title: 'The lines should maintain their colors as their visibility is toggled.', |
| 8 | setup: function(parent) { |
| 9 | parent.innerHTML = |
| 10 | "<div id='blah'></div>" + |
| 11 | "<p><b>Display: </b>" + |
| 12 | "<input type=checkbox id=0 onClick='change(this)' checked>" + |
| 13 | "<label for='0'> a</label>" + |
| 14 | "<input type=checkbox id=1 onClick='change(this)' checked>" + |
| 15 | "<label for='1'> b</label>" + |
| 16 | "<input type=checkbox id=2 onClick='change(this)' checked>" + |
| 17 | "<label for='2'> c</label>" + |
| 18 | "</p>"; |
| 19 | }, |
| 20 | run: function() { |
| 21 | var g = new Dygraph(document.getElementById("blah"), |
| 22 | "X,a,b,c\n" + |
| 23 | "10,12345,23456,34567\n" + |
| 24 | "11,12345,20123,31345\n", |
| 25 | { |
| 26 | width: 640, |
| 27 | height: 480, |
| 28 | colors: ['#284785', '#EE1111', '#8AE234'], |
| 29 | visibility: [true, true, true] |
| 30 | }); |
| 31 | |
| 32 | $('input[type=checkbox]').click(function() { |
| 33 | var el = this; |
| 34 | g.setVisibility(el.id, el.checked); |
| 35 | }); |
| 36 | } |
| 37 | }); |