X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=gallery%2Fplotter.js;h=dfbe4b2e12d885ed3e6c57b230487b3f65ec4488;hb=3c10a0f3519355ee651d04bf2972bd31298eff18;hp=14283c7351ac3ff21181c096ac6d1696b725f8fc;hpb=795b16307db2a673ba7aa3452f6f6b0e93baeb3a;p=dygraphs.git diff --git a/gallery/plotter.js b/gallery/plotter.js index 14283c7..dfbe4b2 100644 --- a/gallery/plotter.js +++ b/gallery/plotter.js @@ -2,34 +2,35 @@ Gallery.register( 'plotter', { - name: 'Plotter', - title: 'title', + name: 'Function Plotter', + title: 'Define your data with functions', setup: function(parent) { parent.innerHTML = "

Equation:
\n" + "
\n" + - "Preset functions: \n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + - "

\n" + + "

\n" + "\n" + "

x range: \n" + " to

\n" + - "

\n" + + "

\n" + "\n" + "
"; }, run: function() { - window.preset = function() { - var sel = document.getElementById("presets").selectedIndex; - var id = document.getElementById("presets").options[sel].id; + var select = document.getElementById("presets"); + select.onchange = function() { + var sel = select.selectedIndex; + var id = select.options[sel].id; var presets = { 'id': [ -10, 10, 'function(x) {\n return x;\n}' ], 'sine': [ -10, 10, 'function(x) {\n return Math.sin(x);\n}' ], @@ -44,7 +45,8 @@ Gallery.register( plot(); } - window.plot = function() { + var plotButton = document.getElementById("plot"); + var plot = function() { var eq = document.getElementById("eq").value; eval("fn = " + eq); @@ -71,5 +73,7 @@ Gallery.register( g = new Dygraph(graph, data); } + plot.onclick = plot; + plot(); } });