| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Label styles</title> |
| 5 | <!-- |
| 6 | For production (minified) code, use: |
| 7 | <script type="text/javascript" src="dygraph-combined.js"></script> |
| 8 | --> |
| 9 | <script type="text/javascript" src="../dygraph-dev.js"></script> |
| 10 | |
| 11 | <script type="text/javascript" src="data.js"></script> |
| 12 | <style type="text/css"> |
| 13 | .dygraph-legend { |
| 14 | background-color: rgba(200, 200, 255, 0.75) !important; |
| 15 | padding: 4px; |
| 16 | border: 1px solid #000; |
| 17 | border-radius: 10px; |
| 18 | box-shadow: 4px 4px 4px #888; |
| 19 | pointer-events: none; |
| 20 | } |
| 21 | pre { |
| 22 | margin-top: 30px; |
| 23 | } |
| 24 | </style> |
| 25 | </head> |
| 26 | <body> |
| 27 | <p>This page demonstrates different values for the <code><a href="http://dygraphs.com/options.html#legend">legend</a></code> option. Mouse over the charts to see the different behaviors.</p> |
| 28 | <pre>legend: "follow":</pre> |
| 29 | <div id="follow" style="width:600px; height:300px;"></div> |
| 30 | |
| 31 | <pre>legend: "always":</pre> |
| 32 | <div id="always" style="width:600px; height:300px;"></div> |
| 33 | |
| 34 | <pre>legend: "never":</pre> |
| 35 | <div id="never" style="width:600px; height:300px;"></div> |
| 36 | |
| 37 | <pre>legend: "onmouseover" (the default):</pre> |
| 38 | <div id="default" style="width:600px; height:300px;"></div> |
| 39 | |
| 40 | <script type="text/javascript"> |
| 41 | function extend(obj1, obj2) { |
| 42 | var obj = {}; |
| 43 | for (var k in obj1) { |
| 44 | obj[k] = obj1[k]; |
| 45 | } |
| 46 | for (var k in obj2) { |
| 47 | obj[k] = obj2[k]; |
| 48 | } |
| 49 | return obj; |
| 50 | } |
| 51 | |
| 52 | var baseOpts = { |
| 53 | rollPeriod: 14, |
| 54 | errorBars: true, |
| 55 | labelsDivWidth: 100, |
| 56 | labelsSeparateLines: true |
| 57 | }; |
| 58 | |
| 59 | g_follow = new Dygraph( |
| 60 | document.getElementById('follow'), |
| 61 | NoisyData, |
| 62 | extend(baseOpts, {legend: 'follow'})); |
| 63 | |
| 64 | g_always = new Dygraph( |
| 65 | document.getElementById('always'), |
| 66 | NoisyData, |
| 67 | extend(baseOpts, {legend: 'always'})); |
| 68 | |
| 69 | g_never = new Dygraph( |
| 70 | document.getElementById('never'), |
| 71 | NoisyData, |
| 72 | extend(baseOpts, {legend: 'never'})); |
| 73 | |
| 74 | g_default = new Dygraph( |
| 75 | document.getElementById('default'), |
| 76 | NoisyData, |
| 77 | baseOpts); |
| 78 | |
| 79 | </script> |
| 80 | </body> |
| 81 | </html> |