Share JSXGraph: example "Highlight curve via slider"

JSXGraph
Share JSXGraph: example "Highlight curve via slider"
This website is a beta version. The official release will be in **2023**.

Highlight curve via slider

Depending on the value of the slider `s`, one of the curves is highlighted.
// Define the id of your board in BOARDID

const board = JXG.JSXGraph.initBoard(BOARDID, {boundingbox: [-10, 10, 10, -10]});

// Slider
var s = board.create('slider', [[1,8],[5,8],[0,0,1]]);

// If s < 0.5: red and thick, else blue and thin
var g = board.create('functiongraph', [(x) => x*x], {
          strokeColor: () => (s.Value() < 0.5) ? 'red' : 'blue',
          strokeWidth: () => (s.Value() < 0.5) ? 4 : 1
});

// If s >= 0.5: red and thick, else blue and thin
var f = board.create('functiongraph', [(x) => x + 1], {
          strokeColor: () => (s.Value() >= 0.5) ? 'red' : 'blue',
          strokeWidth: () => (s.Value() >= 0.5) ? 4 : 1
});