| 1 | /*global Gallery,Dygraph,data */ |
| 2 | Gallery.register( |
| 3 | 'avoid-min-zero', |
| 4 | { |
| 5 | name: "Avoid Min Zero", |
| 6 | setup: function(parent) { |
| 7 | parent.innerHTML = |
| 8 | "<p>1: Line chart with axis at zero problem:</p><div id='graph1'></div> " + |
| 9 | "<p>2: Step chart with axis at zero problem:</p><div id='graphd2'></div> " + |
| 10 | "<p>3: Line chart with <code>avoidMinZero</code> option:</p><div id='graph3'></div> " + |
| 11 | "<p>4: Step chart with <code>avoidMinZero</code> option:</p><div id='graphd4'></div> "; |
| 12 | }, |
| 13 | run: function() { |
| 14 | new Dygraph(document.getElementById("graph1"), |
| 15 | "Date,Temperature\n" + |
| 16 | "2008-05-07,0\n" + |
| 17 | "2008-05-08,1\n" + |
| 18 | "2008-05-09,0\n" + |
| 19 | "2008-05-10,0\n" + |
| 20 | "2008-05-11,3\n" + |
| 21 | "2008-05-12,4\n" |
| 22 | ); |
| 23 | new Dygraph(document.getElementById("graphd2"), |
| 24 | "Date,Temperature\n" + |
| 25 | "2008-05-07,0\n" + |
| 26 | "2008-05-08,1\n" + |
| 27 | "2008-05-09,0\n" + |
| 28 | "2008-05-10,0\n" + |
| 29 | "2008-05-11,3\n" + |
| 30 | "2008-05-12,4\n", |
| 31 | { |
| 32 | stepPlot: true |
| 33 | } |
| 34 | ); |
| 35 | new Dygraph(document.getElementById("graph3"), |
| 36 | "Date,Temperature\n" + |
| 37 | "2008-05-07,0\n" + |
| 38 | "2008-05-08,1\n" + |
| 39 | "2008-05-09,0\n" + |
| 40 | "2008-05-10,0\n" + |
| 41 | "2008-05-11,3\n" + |
| 42 | "2008-05-12,4\n", |
| 43 | { |
| 44 | avoidMinZero: true |
| 45 | } |
| 46 | ); |
| 47 | new Dygraph(document.getElementById("graphd4"), |
| 48 | "Date,Temperature\n" + |
| 49 | "2008-05-07,0\n" + |
| 50 | "2008-05-08,1\n" + |
| 51 | "2008-05-09,0\n" + |
| 52 | "2008-05-10,0\n" + |
| 53 | "2008-05-11,3\n" + |
| 54 | "2008-05-12,4\n", |
| 55 | { |
| 56 | stepPlot: true, |
| 57 | avoidMinZero: true |
| 58 | } |
| 59 | ); |
| 60 | } |
| 61 | }); |