projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generate a source map!
[dygraphs.git]
/
gallery
/
plotter.js
diff --git
a/gallery/plotter.js
b/gallery/plotter.js
index
d077b09
..
08bdf0f
100644
(file)
--- a/
gallery/plotter.js
+++ b/
gallery/plotter.js
@@
-1,4
+1,6
@@
-// Use this as a template for new Gallery entries.
+/*global Gallery,Dygraph,data */
+/*jshint evil:true */
+/*global fn */
Gallery.register(
'plotter',
{
Gallery.register(
'plotter',
{
@@
-27,6
+29,7
@@
Gallery.register(
},
run: function() {
},
run: function() {
+ var plot; // defined below
var select = document.getElementById("presets");
var presets = {
'id': [ -10, 10, 'function(x) {\n return x;\n}' ],
var select = document.getElementById("presets");
var presets = {
'id': [ -10, 10, 'function(x) {\n return x;\n}' ],
@@
-43,15
+46,15
@@
Gallery.register(
document.getElementById("x2").value = presets[id][1];
document.getElementById("eq").value = presets[id][2];
plot();
document.getElementById("x2").value = presets[id][1];
document.getElementById("eq").value = presets[id][2];
plot();
- }
+ }
;
var plotButton = document.getElementById("plot");
var plotButton = document.getElementById("plot");
-
var
plot = function() {
+ plot = function() {
var eq = document.getElementById("eq").value;
eval("fn = " + eq);
var graph = document.getElementById("graph_div");
var eq = document.getElementById("eq").value;
eval("fn = " + eq);
var graph = document.getElementById("graph_div");
- var width = parseInt(graph.style.width);
+ var width = parseInt(graph.style.width
, 10
);
var x1 = parseFloat(document.getElementById("x1").value);
var x2 = parseFloat(document.getElementById("x2").value);
var xs = 1.0 * (x2 - x1) / width;
var x1 = parseFloat(document.getElementById("x1").value);
var x2 = parseFloat(document.getElementById("x2").value);
var xs = 1.0 * (x2 - x1) / width;
@@
-71,8
+74,8
@@
Gallery.register(
data.push(row);
}
data.push(row);
}
-
g =
new Dygraph(graph, data);
- }
+ new Dygraph(graph, data);
+ }
;
plotButton.onclick = plot;
plot();
}
plotButton.onclick = plot;
plot();
}