3👍
✅
Use math.js to parse the string input into a function.
// If "input" is a variable representing the string input for y
var f = math.eval('f(x) = ' + input');
Then compute a range of values for f to pass into chart.js:
// If "min" and "max" are values representing the minimum and max values
var values = [],
var x = min;
var increment = (max - min) / 10000;
for (var i = 0; i < 10000; i++)
values[i] = f(x + increment * i);
Source:stackexchange.com