Difference between revisions of "Data plot"
From JSXGraph Wiki
Jump to navigationJump to searchA WASSERMANN (talk | contribs) |
A WASSERMANN (talk | contribs) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
var minY = 100000.0; | var minY = 100000.0; | ||
− | var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[- | + | var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-1,5000,25,-400],axis:true}); |
var plotData = function() { | var plotData = function() { | ||
Line 12: | Line 12: | ||
var t = document.getElementById('in_data').value; | var t = document.getElementById('in_data').value; | ||
var data = t.split('\n'); | var data = t.split('\n'); | ||
− | |||
for (i=0;i<data.length-1;i++) { | for (i=0;i<data.length-1;i++) { | ||
d = data[i].split(';'); | d = data[i].split(';'); | ||
− | x[i] = d[ | + | x[i] = d[0]*1.0; |
− | y[i] = d[ | + | y[i] = d[1]*1.0; |
if (x[i]>maxX) maxX = x[i]; | if (x[i]>maxX) maxX = x[i]; | ||
if (y[i]>maxY) maxY = y[i]; | if (y[i]>maxY) maxY = y[i]; | ||
if (y[i]<minY) minY = y[i]; | if (y[i]<minY) minY = y[i]; | ||
} | } | ||
− | brd.setBoundingBox([- | + | brd.setBoundingBox([-1,maxY*1.01,maxX*1.05,minY*0.95]); |
var c = brd.create('curve',[x,y],{strokeColor:color[nr%color.length]}); | var c = brd.create('curve',[x,y],{strokeColor:color[nr%color.length]}); | ||
nr++; | nr++; | ||
Line 29: | Line 28: | ||
var clearBoard = function() { | var clearBoard = function() { | ||
JXG.JSXGraph.freeBoard(brd); | JXG.JSXGraph.freeBoard(brd); | ||
− | brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-100,5000, | + | brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-100,5000,25,-400],axis:true}); |
maxX = 0.0; | maxX = 0.0; | ||
maxY = 0.0; | maxY = 0.0; |