Published unlisted
Edited
May 10, 2021
Fork of Math Plot
Insert cell
Insert cell
// my custom text input
viewof expr = MyText({
labelWidth: "50px",
submit: true,
label: tex`f(x)=`,
value: "x*sin(x^2)"
})
Insert cell
Insert cell
Insert cell
// ⭐️ add a "labelWidth" option
MyText = ({ labelWidth = "100px", ...options } = {}) => {
let input = Text(options);
$("label", input).style.width = labelWidth;
return input;
}
Insert cell
// ⭐️ function expression (text) -> funplot
plot = (text) => {
let f = math.compile(text);
return funplot((x) => f.evaluate({ x: x }));
}
Insert cell
function $(selector, parent = document) {
return parent.querySelector(selector);
}
Insert cell
// $all ⭐️
function $all(selector, parent = document) {
return parent.querySelectorAll(selector);
}
Insert cell
Insert cell
Insert cell
Insert cell
// ⭐️ import math.js
math = require("mathjs@9")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more