Difference between revisions of "Plot data with slider"

From JSXGraph Wiki
Jump to: navigation, search
Line 1: Line 1:
 
<jsxgraph width="600" height="300" box="box1">
 
<jsxgraph width="600" height="300" box="box1">
var plotdata = [
+
var plotData = [
 
   [0, 1, 2, 3, 4, 5, 6, 7],
 
   [0, 1, 2, 3, 4, 5, 6, 7],
 
   [40, -1, 1, -40, -40, 1, 1, 40]
 
   [40, -1, 1, -40, -40, 1, 1, 40]
Line 8: Line 8:
  
 
var mu = brd.create('slider', [[2.5,30], [5,30], [0, 1, 1]], {name:'&mu;'});
 
var mu = brd.create('slider', [[2.5,30], [5,30], [0, 1, 1]], {name:'&mu;'});
var plot = brd.create('curve', plotdata, {type:'plot'});
+
var plot = brd.create('curve', plotData, {type:'plot'});
 +
 
 +
plot.updateDataArray = function() {
 +
    var i, len = plotdata[0].length;
 +
   
 +
    for (i = 0; i < len; i++) {
 +
        this.dataY[i] = plotData[1] * mu.Value();
 +
    }
 +
};
 +
 
 
</jsxgraph>
 
</jsxgraph>
  

Revision as of 09:37, 12 April 2014

The JavaScript code