Published
Edited
Feb 15, 2021
Fork of Untitled
Insert cell
Insert cell
Insert cell
function eq(str) {
return html`<img style="vertical-align: text-bottom" src="https://s.mathequationapi.com/m?eq=${encodeURIComponent(
str
)}" />`;
}
Insert cell
Insert cell
eq('a+b+c = 100')
Insert cell
Insert cell
html`If ${eq('f(x)=e^{-x^2}')}, then
<div style="text-align: center">
${eq(String.raw`\int_{-\infty}^{\infty} f(x) \, dx = \sqrt{\pi}`)}
</div>
`
Insert cell
Insert cell
async function eq_svg(s) {
let svg_math = await (await fetch(
`https://s.mathequationapi.com/m?eq=${s}`
)).text();
return svg`${svg_math}`;
}
Insert cell
Insert cell
{
const plot = plotter();
plot.circle(0, 0, 6, { stroke: 'black', width: 3 });
let pir2 = await eq_svg(String.raw`\pi r^2`);
d3.select(plot.node)
.append('g')
.attr('transform', 'scale(3) translate(65,48)')
.append(() => pir2);
return plot.node;
}
Insert cell
Insert cell
Insert cell
import { plotter } from '@kjerandp/plotter'
Insert cell
d3 = require('d3-selection@2')
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