1 // Copyright (c) 2012 Google, Inc.
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * @fileoverview Javascript to run index.html.
24 * @author konigsberg@google.com (Robert Konigsberg)
29 function draw(element
, options
) {
31 element
.innerHTML
= "";
32 element
.removeAttribute("style");
36 var zp
= function(x
) { if (x
< 10) return "0"+x
; else return x
; };
37 var r
= "date,parabola,line,another line,sine wave\n";
38 for (var i
=1; i
<=31; i
++) {
39 r
+= "201110" + zp(i
);
40 r
+= "," + 10*(i
*(31-i
));
42 r
+= "," + 10*(250 - 8*i
);
43 r
+= "," + 10*(125 + 125 * Math
.sin(0.3*i
));
50 // These don't work yet.
61 function addMessage(text
) {
62 var messages
= document
.getElementById("messages");
63 messages
.innerText
= messages
.innerText
+ text
+ "\n";
74 labelsSeparateLines
: true,
79 title
: 'Interesting Shapes',
82 axisLineColor
: 'white',
84 pointClickCallback
: function() { alert("p-click!"); },
87 var redraw
= function() {
88 draw(document
.getElementById("graph"), palette
.read());
91 var palette
= new Palette();
92 palette
.create(document
, document
.getElementById("optionsPalette"));
93 palette
.write(options
);
94 palette
.onchange
= redraw
;
95 palette
.filterBar
.focus();
98 for (var opt
in Dygraph
.OPTIONS_REFERENCE
) {
100 var entry
= Dygraph
.OPTIONS_REFERENCE
[opt
];
101 console
.warn("missing option: " + opt
+ " of type " + entry
.type
);