In jsxgraph, I want to draw a line between two points that is solid if the first point is on the left of the other but that is dashed otherwise. I want the appearance of the line to change dynamically when I move the first point around, with the mouse.
I have tried the following ways
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-7, 5, 12, -5], axis:true, keepAspectRatio:true});
var p1 = board.create('point', [-1, 0]);
var p2 = board.create('point', [0, 0]);
var s = board.create('segment', [p1, p2]);
if (p1.XEval()>0) {s.setProperty({dash:2});}
and
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-7, 5, 12, -5], axis:true, keepAspectRatio:true});
var p1 = board.create('point', [-1, 0]);
var p2 = board.create('point', [0, 0]);
var s = board.create('segment', [p1, p2], {function(){if (p1.XEval()>0) {return 'dash:2';}}});
but they did not work (the line is always solid).
Thank you for any hint !!