1 /*global Gallery,Dygraph,data */
6 title
: 'Graph edge padding and axis position',
7 setup
: function(parent
) {
9 "<style>.dygraph-legend { width: 100px; }</style>" +
12 " <input type='radio' name='mode'>use {x,y}RangePad</input>" +
13 " <input type='radio' name='mode'>original</input>" +
14 " <br /><b>Settings:</b>" +
15 " <input type='checkbox' id='yrange'>valueRange=[-2,2]</input>" +
17 "<div id='demodiv'></div>"
21 var parent
= document
.getElementById("demodiv");
26 for (var oy
= -2; oy
<= 2; ++oy
) {
27 for (var ox
= -1; ox
<= 1; ++ox
) {
28 var gdiv
= document
.createElement('div');
29 gdiv
.style
.display
= 'inline-block';
30 gdiv
.style
.margin
= '2px';
31 parent
.appendChild(gdiv
);
34 for (var row
= 0; row
< nrows
; ++row
) {
35 var x
= row
* 5 / (nrows
- 1);
36 data
.push([ox
* 2.5 + x
- 2.5,
38 oy
+ Math
.round(Math
.cos(x
))]);
41 var g
= new Dygraph(gdiv
, data
, {
42 labels
: ['x', 'A', 'B'],
43 gridLineColor
: '#ccc',
50 parent
.appendChild(document
.createElement('br'));
53 var updateGraphOpts
= function(opts
) {
54 for (var i
= 0; i
< graphs
.length
; ++i
) {
55 graphs
[i
].updateOptions(opts
);
59 var mode
= document
.getElementsByName('mode');
60 mode
[0].onchange
= function() {
65 drawAxesAtZero
: true});
67 mode
[1].onchange
= function() {
72 drawAxesAtZero
: false});
74 mode
[0].checked
= true;
77 var yrange
= document
.getElementById('yrange');
78 yrange
.onchange
= function(ev
) {
80 valueRange
: ev
.target
.checked
? [-2, 2] : null});