| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9"> |
| 5 | <title>connect separated</title> |
| 6 | <!--[if IE]> |
| 7 | <script type="text/javascript" src="../excanvas.js"></script> |
| 8 | <![endif]--> |
| 9 | <!-- |
| 10 | For production (minified) code, use: |
| 11 | <script type="text/javascript" src="dygraph-combined.js"></script> |
| 12 | --> |
| 13 | <script type="text/javascript" src="../dygraph-dev.js"></script> |
| 14 | |
| 15 | </head> |
| 16 | <body> |
| 17 | <p>Connecting separated points. All three of the series should have their points |
| 18 | connected with lines, and hovering over them should produce dot and legend |
| 19 | overlays in the proper color.</p> |
| 20 | |
| 21 | <div id="graphdiv" style="width:600px; height:300px;"></div> |
| 22 | <p><b>Toggle ConnectSeparated:<b></p> |
| 23 | <p> |
| 24 | All: <button id="All" onclick="change(this)">true</button> |
| 25 | Series 1 <button id="Series1" onclick="change(this)">disabled</button> |
| 26 | Series 2 <button id="Series2" onclick="change(this)">disabled</button> |
| 27 | Series 3 <button id="Series3" onclick="change(this)">disabled</button> |
| 28 | </p> |
| 29 | <script type="text/javascript"> |
| 30 | var g = new Dygraph(document.getElementById("graphdiv"), |
| 31 | [ |
| 32 | [ new Date("2009/12/01"), 10, 10, 10], |
| 33 | [ new Date("2009/12/02"), 15, 11, 12], |
| 34 | [ new Date("2009/12/03"), null, null, 12], |
| 35 | [ new Date("2009/12/04"), 20, 14, null], |
| 36 | [ new Date("2009/12/05"), 15, null, 17], |
| 37 | [ new Date("2009/12/06"), 18, null, null], |
| 38 | [ new Date("2009/12/07"), 12, 14, null] |
| 39 | ], |
| 40 | { |
| 41 | connectSeparatedPoints: true, |
| 42 | labels: ["Date","Series1","Series2","Series3"] |
| 43 | }); |
| 44 | |
| 45 | function change(el) { |
| 46 | var textSequences = [ "disabled", "true", "false" ]; |
| 47 | var values = [ null, true, false ]; |
| 48 | for (var idx = 0; idx < textSequences.length; idx++) { |
| 49 | if (textSequences[idx] == el.textContent) { |
| 50 | var nextIdx = (idx + 1) % 3; |
| 51 | var nextVal = values[nextIdx]; |
| 52 | el.textContent = textSequences[nextIdx]; |
| 53 | |
| 54 | if (el.id == "All") { |
| 55 | g.updateOptions({ connectSeparatedPoints : nextVal }); |
| 56 | } else { |
| 57 | var seriesOpt = {}; |
| 58 | seriesOpt[el.id] = { connectSeparatedPoints : nextVal }; |
| 59 | g.updateOptions({ series : seriesOpt }); |
| 60 | } |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | </script> |
| 66 | </body> |
| 67 | </html> |