+/*global Gallery,Dygraph,data */
+/*global google */
Gallery.register(
'annotations-gviz',
{
"<div id='dg_div' style='width: 700px; height: 240px;'></div>";
},
run: function() {
- drawChart = function() {
+ var drawChart = function() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Sold Pencils');
+/*global Gallery,Dygraph,data */
Gallery.register(
'annotations-native',
{
"<div id='demodiv'></div>";
},
run: function() {
- g = new Dygraph(
+ var g = new Dygraph(
document.getElementById("demodiv"),
[
[ new Date("2011/11/01"), 100 ],
+/*global Gallery,Dygraph,data */
Gallery.register(
'annotations',
{
return "(" + ann.series + ", " + ann.x + ")";
}
- g = new Dygraph(
+ var g = new Dygraph(
document.getElementById("g_div"),
function() {
var zp = function(x) { if (x < 10) return "0"+x; else return x; };
);
var last_ann = 0;
- annotations = [];
+ var annotations = [];
for (var x = 10; x < 15; x += 2) {
annotations.push( {
series: 'sine wave',
document.getElementById('add').onclick = function() {
var x = last_ann + 2;
- var annnotations = g.annotations();
annotations.push( {
series: 'line',
x: "200610" + x,
+/*global Gallery,Dygraph,data */
Gallery.register(
'avoid-min-zero',
{
"<p>4: Step chart with <code>avoidMinZero</code> option:</p><div id='graphd4'></div> ";
},
run: function() {
- var g1 = new Dygraph(document.getElementById("graph1"),
+ new Dygraph(document.getElementById("graph1"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
"2008-05-08,1\n" +
"2008-05-11,3\n" +
"2008-05-12,4\n"
);
- var g2 = new Dygraph(document.getElementById("graphd2"),
+ new Dygraph(document.getElementById("graphd2"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
"2008-05-08,1\n" +
stepPlot: true
}
);
- var g3 = new Dygraph(document.getElementById("graph3"),
+ new Dygraph(document.getElementById("graph3"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
"2008-05-08,1\n" +
avoidMinZero: true
}
);
- var g4 = new Dygraph(document.getElementById("graphd4"),
+ new Dygraph(document.getElementById("graphd4"),
"Date,Temperature\n" +
"2008-05-07,0\n" +
"2008-05-08,1\n" +
+/*global Gallery,Dygraph,data */
Gallery.register(
'border',
{
"<div id='bordered' style='border: 1px solid red; width:600px; height:300px;'></div>";
},
run: function() {
- var g = new Dygraph(document.getElementById('bordered'), data,
+ new Dygraph(document.getElementById('bordered'), data,
{
labelsDivStyles: { border: '1px solid black' },
title: 'Chart Title',
+/*global Gallery,Dygraph,data */
+/*global NoisyData */
Gallery.register(
'callbacks',
{
"<div id='status' style='width:100%; height:200px;'></div>";
},
run: function() {
+ var g = null;
var showLabels = document.getElementById('showLabels');
showLabels.onclick = function() {
g.updateOptions({showLabelsOnHighlight: showLabels.checked});
};
document.getElementById('clear').onclick = clearStatus;
- var g = null;
- pts_info = function(e, x, pts, row) {
+ var pts_info = function(e, x, pts, row) {
var str = "(" + x + ") ";
for (var i = 0; i < pts.length; i++) {
var p = pts[i];
+/*global Gallery,Dygraph,data */
Gallery.register(
'color-cycle',
{
['#444444', '#888888', '#DDDDDD'],
null
];
- chart = new Dygraph(document.getElementById("blah"),
+ var chart = new Dygraph(document.getElementById("blah"),
"X,a,b,c\n" +
"10,12345,23456,34567\n" +
"11,12345,20123,31345\n",
+/*global Gallery,Dygraph,data,$ */
+/*jshint unused:false */
Gallery.register(
'color-visibility',
{
visibility: [true, true, true]
});
- function change(el) {
- g.setVisibility(el.id, el.checked);
- }
+ $('input[type=checkbox]').click(function() {
+ var el = this;
+ g.setVisibility(el.id, el.checked);
+ });
}
});
+/*global Gallery,Dygraph,data */
Gallery.register(
'demo',
{
"</tr></table>";
},
run: function() {
- var g = new Dygraph(
+ new Dygraph(
document.getElementById("demodiv"),
function() {
var zp = function(x) { if (x < 10) return "0"+x; else return x; };
+/*global Gallery,Dygraph,data */
Gallery.register(
'drawing',
{
},
run: function() {
+ var change_tool; // defined below.
var zoom = document.getElementById('tool_zoom');
zoom.onclick = function() { change_tool(zoom); };
var pencil = document.getElementById('tool_pencil');
lastDrawValue = null;
}
- var change_tool = function(tool_div) {
+ change_tool = function(tool_div) {
var ids = ['tool_zoom', 'tool_pencil', 'tool_eraser'];
for (var i = 0; i < ids.length; i++) {
var div = document.getElementById(ids[i]);
};
change_tool(document.getElementById("tool_pencil"));
- g = new Dygraph(document.getElementById("draw_div"), data,
+ new Dygraph(document.getElementById("draw_div"), data,
{
valueRange: valueRange,
labels: [ 'Date', 'Value' ],
+/*global Gallery,Dygraph,data */
Gallery.register(
'dygraph-simple',
{
"<p>Same data, specified in a parsed format:</p><div id='graphdiv2'></div>";
},
run: function() {
- g = new Dygraph(document.getElementById("graphdiv"),
+ new Dygraph(document.getElementById("graphdiv"),
"Date,Temperature\n" +
"2008-05-07,75\n" +
"2008-05-08,70\n" +
"2008-05-09,80\n");
- g2 = new Dygraph(document.getElementById("graphdiv2"),
+ new Dygraph(document.getElementById("graphdiv2"),
[ [ new Date("2008/05/07"), 75],
[ new Date("2008/05/08"), 70],
[ new Date("2008/05/09"), 80]
+/*global Gallery,Dygraph,data */
Gallery.register(
'dynamic-update',
{
+/*global Gallery,Dygraph,data */
Gallery.register(
'edge-padding',
{
// Use this as a template for new Gallery entries.
+/*global Gallery,Dygraph,data */
Gallery.register(
'id',
{
parent.innerHTML = "<div id='blah'>";
},
run: function() {
- g = new Dygraph(document.getElementById("blah"),
+ new Dygraph(document.getElementById("blah"),
"X,Y\n10,12345\n11,12345\n", {});
}
});
/*jshint loopfunc:true */
+/*global Dygraph,$,TextArea,jQuery */
var Gallery = {};
Gallery.entries = {};
+/*global Gallery,Dygraph,data */
Gallery.register(
'highlighted-region',
{
data[i][2] += 5.0;
}
- var g = new Dygraph(
+ new Dygraph(
document.getElementById("div_g"),
data,
{
+/*global Gallery,Dygraph,data */
Gallery.register(
'highlighted-series',
{
+/*global Gallery,Dygraph,data */
Gallery.register(
'highlighted-weekends',
{
"2011-01-30," + Math.random()*100 + "\n" +
"2011-01-31," + Math.random()*100 + "\n";
- var g = new Dygraph(
+ new Dygraph(
document.getElementById("div_g"),
data,
{
// get day of week
var d = new Date(min_data_x);
var dow = d.getUTCDay();
- var ds = d.toUTCString();
var w = min_data_x;
// starting on Sunday is a special case
+/*global Gallery,Dygraph,data */
Gallery.register(
'independent-series',
{
" [10, 10, null]\n" +
"]";
- var g1 = new Dygraph(
+ new Dygraph(
document.getElementById('graph'),
[
[1, null, 3],
}
);
- g2 = new Dygraph(
+ new Dygraph(
document.getElementById('graph2'),
'x,A,B \n' +
'1,,3 \n' +
+/*global Dygraph */
// Code for a variety of interaction models. Used in interaction.html, but split out from
// that file so they can be tested in isolation.
//
+/*global Gallery,Dygraph,data */
+/*global NoisyData,downV3,moveV3,upV3,clickV3,dblClickV3,scrollV3,restorePositioning,downV4,moveV4,upV4,dblClickV4,captureCanvas */
+
Gallery.register(
'interaction',
{
},
run: function() {
+ var lastClickedGraph;
// TODO(konigsberg): Add cleanup to remove callbacks.
Dygraph.addEvent(document, "mousewheel", function() { lastClickedGraph = null; });
Dygraph.addEvent(document, "click", function() { lastClickedGraph = null; });
- var g = new Dygraph(document.getElementById("div_g"),
+ new Dygraph(document.getElementById("div_g"),
NoisyData, { errorBars : true });
- var s = document.getElementById("g2_console");
- var g2 = new Dygraph(document.getElementById("div_g2"),
+ new Dygraph(document.getElementById("div_g2"),
NoisyData,
{
errorBars : true,
document.getElementById("restore3").onclick = function() {
restorePositioning(g3);
};
- var g4 = new Dygraph(document.getElementById("div_g4"),
+ new Dygraph(document.getElementById("div_g4"),
NoisyData, {
errorBars : true,
drawPoints : true,
+/*global Gallery,Dygraph,data */
Gallery.register(
'linear-regression',
{
"</div>"].join("\n");
},
run: function() {
+ var g, regression, clearLines; // defined below
document.getElementById("ry1").onclick = function() { regression(1); };
document.getElementById("ry2").onclick = function() { regression(2); };
document.getElementById("clear").onclick = function() { clearLines(); };
// if coeffs = [ null, [1, 2], null ] then we draw a regression for series 1
// only. The regression line is y = 1 + 2 * x.
var coeffs = [ null, null, null ];
- function regression(series) {
+ regression = function(series) {
// Only run the regression over visible points.
var range = g.xAxisRange();
}
g.updateOptions({}); // forces a redraw.
- }
+ };
- function clearLines() {
+ clearLines = function() {
for (var i = 0; i < coeffs.length; i++) coeffs[i] = null;
g.updateOptions({});
- }
+ };
function drawLines(ctx, area, layout) {
if (typeof(g) == 'undefined') return; // won't be set on the initial draw.
+/*global Gallery,Dygraph,data */
Gallery.register(
'link-interaction',
{
]);
}
var orig_range = [ r[0][0].valueOf(), r[r.length - 1][0].valueOf() ];
- g = new Dygraph(
+ var g = new Dygraph(
document.getElementById("div_g"),
r, {
rollPeriod: 7,
}
);
- var desired_range = null;
+ var desired_range = null, animate;
function approach_range() {
if (!desired_range) return;
// go halfway there
animate();
}
}
- function animate() {
+ animate = function() {
setTimeout(approach_range, 50);
- }
+ };
var zoom = function(res) {
var w = g.xAxisRange();
+/*global Gallery,Dygraph,data */
Gallery.register(
'negative',
{
pos.push([i, 1000 + 2 * i, 1100 + i]);
}
- var g1 = new Dygraph(
+ new Dygraph(
document.getElementById("g1"),
negs, { labels: [ 'x', 'y1', 'y2' ] }
);
- var g2 = new Dygraph(
+ new Dygraph(
document.getElementById("g2"),
mixed, { labels: [ 'x', 'y1', 'y2' ] }
);
- var g3 = new Dygraph(
+ new Dygraph(
document.getElementById("g3"),
pos, { labels: [ 'x', 'y1', 'y2' ] }
);
+/*global Gallery,Dygraph,data */
Gallery.register(
'no-range',
{
"<div id='blah2'></div>";
},
run: function() {
- var g1 = new Dygraph(document.getElementById("blah"),
+ new Dygraph(document.getElementById("blah"),
"X,Y\n10,12345\n11,12345\n",
{ width: 640, height: 480 });
- var g2 = new Dygraph(document.getElementById("blah2"),
+ new Dygraph(document.getElementById("blah2"),
"date,10M\n" +
"20021229,10000000.000000\n" +
"20030105,10000000.000000\n" +
+/*global Gallery,Dygraph,data */
Gallery.register(
'number-format',
{
run: function() {
// Helper functions for generating an HTML table for holding the test
// results.
- createRow = function(columnType, columns) {
+ var createRow = function(columnType, columns) {
var row = document.createElement('tr');
for (var i = 0; i < columns.length; i ++) {
var th = document.createElement(columnType);
return row;
};
- createHeaderRow = function(columns) {
+ var createHeaderRow = function(columns) {
return createRow('th', columns);
};
- createDataRow = function(columns) {
+ var createDataRow = function(columns) {
return createRow('td', columns);
};
- createTable = function(headerColumns, dataColumnsList) {
+ var createTable = function(headerColumns, dataColumnsList) {
var table = document.createElement('table');
table.appendChild(createHeaderRow(headerColumns));
for (var i = 0; i < dataColumnsList.length; i++) {
return table;
};
- updateTable = function() {
+ var updateTable = function() {
var headers = ['Dygraph.floatFormat()', 'toPrecision()',
'Dygraph.floatFormat()', 'toPrecision()'];
var numbers = [];
+/*global Gallery,Dygraph,data */
Gallery.register(
'per-series',
{
parent.innerHTML = "<div id='demodiv'>";
},
run: function() {
- g = new Dygraph(
+ new Dygraph(
document.getElementById("demodiv"),
function() {
var zp = function(x) { if (x < 10) return "0"+x; else return x; };
+/*global Gallery,Dygraph,data */
/*jshint evil:true */
+/*global fn */
Gallery.register(
'plotter',
{
},
run: function() {
+ var plot; // defined below
var select = document.getElementById("presets");
var presets = {
'id': [ -10, 10, 'function(x) {\n return x;\n}' ],
};
var plotButton = document.getElementById("plot");
- var plot = function() {
+ plot = function() {
var eq = document.getElementById("eq").value;
eval("fn = " + eq);
data.push(row);
}
- g = new Dygraph(graph, data);
+ new Dygraph(graph, data);
};
plotButton.onclick = plot;
plot();
+/*global Gallery,Dygraph,data */
+/*global data_temp */
Gallery.register(
'range-selector',
{
"<div id='roll14' style='width:600px; height:300px;'></div>"].join("\n");
},
run: function() {
- g1 = new Dygraph(
+ new Dygraph(
document.getElementById("noroll"),
data_temp,
{
showRangeSelector: true
}
);
- g2 = new Dygraph(
+ new Dygraph(
document.getElementById("roll14"),
data_temp,
{
+/*global Gallery,Dygraph,data */
+/*global NoisyData */
Gallery.register(
'resize',
{
parent.innerHTML = "<div id='div_g'>";
},
run: function() {
- g = new Dygraph(
+ new Dygraph(
document.getElementById("div_g"),
NoisyData, {
rollPeriod: 7,
+/*global Gallery,Dygraph,data */
+/*global stockData */
Gallery.register(
'stock',
{
var linear = document.getElementById("linear");
var log = document.getElementById("log");
- linear.onclick = function() { setLog(false); };
- log.onclick = function() { setLog(true); };
var setLog = function(val) {
g.updateOptions({ logscale: val });
linear.disabled = !val;
log.disabled = val;
};
+ linear.onclick = function() { setLog(false); };
+ log.onclick = function() { setLog(true); };
}
});
+/*global Gallery,Dygraph,data */
Gallery.register(
'styled-chart-labels',
{
"<div class='chart' id='div_g2' style='width:600px; height:300px;'></div>"].join("\n");
},
run: function() {
- g = new Dygraph(
+ new Dygraph(
document.getElementById("div_g"),
data, {
rollPeriod: 7,
}
);
- g2 = new Dygraph(
+ new Dygraph(
document.getElementById("div_g2"),
data, {
rollPeriod: 30,
+/*global Gallery,Dygraph,data */
/*jshint loopfunc:true */
+/*global NoisyData */
Gallery.register(
'synchronize',
{
"<td><div id='div4' style='width:500px; height:300px;'></div></td></table>"].join("\n");
},
run: function() {
- gs = [];
+ var gs = [];
var blockRedraw = false;
for (var i = 1; i <= 4; i++) {
gs.push(
+/*global Gallery,Dygraph,data */
+/*global data_temp */
Gallery.register(
// Get a better name.
'temperature-sf-ny',
.join("\n");
},
run: function() {
- g1 = new Dygraph(
+ new Dygraph(
document.getElementById("noroll"),
data_temp,
{
labelsDivStyles: { 'textAlign': 'right' }
}
);
- g2 = new Dygraph(
+ new Dygraph(
document.getElementById("roll14"),
data_temp,
{
}
);
}
- });
\ No newline at end of file
+ });
+/*global Gallery,Dygraph,data */
Gallery.register(
'two-axes',
{
"<input type='checkbox' id='check'><label for='check'> Fill?</label>";
},
run: function() {
+ var g, g2;
document.getElementById('check').onchange = function(el) {
g.updateOptions( { fillGraph: el.checked } );
g2.updateOptions( { fillGraph: el.checked } );