Equation IO API for the web
Draft API:
var EquationIO = require('equation-io-api');
var Graph = EquationIO.Graph;
var div = document.createElement('div');
// It needs to be in the DOM hierarchy, but we can make it hidden to avoid artefacts before it finishes loading:
div.style.opacity = 0.0;
document.body.appendChild(div);
var graph = new Graph({width: 800, height: 600});
graph.init(div, function (err) {
console.log('loaded');
div.style.opacity = 1.0;
});
// To implement later:
// graph.context.c = 30;
// Change what is displayed by modifying the .equations array:
graph.equations.push({
latex: 'y = \\sin x',
color: 'red'
});
graph.equations.push({
latex: 'y = \\cos x',
color: 'blue'
});
// And then call .update()
graph.update(function (err) {
if (err) alert(err.message);
console.log('Graph should now have two curves');
});