1 /*global Gallery,Dygraph,data */
6 title
: 'Graph edge padding and axis position',
7 setup
: function(parent
) {
11 " <input type='radio' name='mode'>use {x,y}RangePad</input>" +
12 " <input type='radio' name='mode'>original</input>" +
13 " <br /><b>Settings:</b>" +
14 " <input type='checkbox' id='yrange'>valueRange=[-2,2]</input>" +
16 "<div id='demodiv'></div>"
20 var parent
= document
.getElementById("demodiv");
25 for (var oy
= -2; oy
<= 2; ++oy
) {
26 for (var ox
= -1; ox
<= 1; ++ox
) {
27 var gdiv
= document
.createElement('div');
28 gdiv
.style
.display
= 'inline-block';
29 gdiv
.style
.margin
= '2px';
30 parent
.appendChild(gdiv
);
33 for (var row
= 0; row
< nrows
; ++row
) {
34 var x
= row
* 5 / (nrows
- 1);
35 data
.push([ox
* 2.5 + x
- 2.5,
37 oy
+ Math
.round(Math
.cos(x
))]);
40 var g
= new Dygraph(gdiv
, data
, {
41 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});