Add sparse sample, rename variable.
[dygraphs.git] / experimental / palette / samples.js
CommitLineData
3dcf1f1f
RK
1// Copyright (c) 2012 Google, Inc.
2//
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:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
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
19// THE SOFTWARE.
20
21/**
22 * @fileoverview Source samples.
23 *
24 * @author konigsberg@google.com (Robert Konigsberg)
25 */
26
27"use strict";
28
29var Samples = {
30 interestingShapes: {
31 data: function() {
32 var zp = function(x) { if (x < 10) return "0"+x; else return x; };
33 var r = "date,parabola,line,another line,sine wave\n";
34 for (var i=1; i<=31; i++) {
35 r += "201110" + zp(i);
36 r += "," + 10*(i*(31-i));
37 r += "," + 10*(8*i);
38 r += "," + 10*(250 - 8*i);
39 r += "," + 10*(125 + 125 * Math.sin(0.3*i));
40 r += "\n";
41 }
42 return r;
43 },
44 options: {
45 colors: [
46 "rgb(51,204,204)",
47 "rgb(255,100,100)",
48 "#00DD55",
49 "rgba(50,50,200,0.4)"
50 ],
51 labelsSeparateLines: true,
52 labelsKMB: true,
53 legend: 'always',
54 width: 640,
55 height: 480,
56 title: 'Interesting Shapes',
57 xlabel: 'Date',
58 ylabel: 'Count',
59 axisLineColor: 'white',
60 drawXGrid: false,
61 pointClickCallback: function() { alert("p-click!"); },
62 }
63 },
64
65 sparse: {
66 data: [
67 [ new Date("2009/12/01"), 10, 10, 10],
68 [ new Date("2009/12/02"), 15, 11, 12],
69 [ new Date("2009/12/03"), null, null, 12],
70 [ new Date("2009/12/04"), 20, 14, null],
71 [ new Date("2009/12/05"), 15, null, 17],
72 [ new Date("2009/12/06"), 18, null, null],
73 [ new Date("2009/12/07"), 12, 14, null]
74 ],
75 options: {
76 labels: ["Date", "Series1", "Series2", "Series3"]
77 }
78 },
79
80 manyPoints: {
81 data: function() {
82 var numPoints = 1000;
83 var numSeries = 100;
84
85 var data = [];
86 var xmin = 0.0;
87 var xmax = 2.0 * Math.PI;
88 var adj = .5;
89 var delta = (xmax - xmin) / (numPoints - 1);
90
91 for (var i = 0; i < numPoints; ++i) {
92 var x = xmin + delta * i;
93 var elem = [ x ];
94 for (var j = 0; j < numSeries; j++) {
95 var y = Math.pow(Math.random() - Math.random(), 7);
96 elem.push(y);
97 }
98 data[i] = elem;
99 }
100 return data;
101 },
102 options: {
103 labelsSeparateLines: true,
104 width: 640,
105 height: 480,
106 title: 'Many Points',
107 axisLineColor: 'white',
108 }
109 }
110}