Hi friends!
I'm new in this group, I just started to use JSXGraphs and I love it!
I have to do a chart which shows an area between two X-axis coordinates. I've been using a "polygon" but I wish I would change it dynamically with sliders. The problem is that moving the start and end points, do not recalculate the intermediate points of the polygon to display the new area.
You can show my problem in
You can see a picture of my problem on this link:
http://img87.imageshack.us/img87/9150/graphri.pngThis is the code of this part:
-----------------------------------------------------------------------------------------------------
//Sliders
var n = brd.createElement('slider', [[10, 5.7],[50,5.7],[0,10,70]], {name:'seg', snapWidth:1});
var m = brd.createElement('slider', [[10, 5.3],[50,5.3],[0,20,70]], {name:'seg', snapWidth:1});
// Points of the area
g1 = brd.createElement('point', [function(){ return n.Value()}, function(){ return y[Math.floor(n.Value())]}], {});
g2 = brd.createElement('point', [function(){ return n.Value()}, 0], {});
g3 = brd.createElement('point', [function(){ return m.Value()}, function(){ return y[Math.floor(m.Value())]}], {});
g4 = brd.createElement('point', [function(){ return m.Value()}, 0], {});
area.push(g3);
area.push(g4);
area.push(g2);
area.push(g1);
for (j = start; j <= end; j++) {
if (j > n.Value() && j < m.Value()) {
area.push(brd.createElement('point', [j, y[j]], {}));
}
}
pol = brd.createElement('polygon', area, {});
-----------------------------------------------------------------------------------------------------
Thanks for your help!
Emilio, Spain ;)