Published
Edited
Jun 17, 2018
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
multi_plot = html`
<svg width="${width}" height="${height}"
stroke="#b02" stroke-width="0.1" fill="random">
${rows.map(j => cols.map(i =>
`<path d="${bezlissajous(i,j)}Z" transform="${transform(i,j)}" />`
).join('\n ')).join('\n ')}
</svg>`
Insert cell
Insert cell
single_plot = html`
<svg width="${width}" height="${width}"
stroke="#b02" stroke-width="0.02" fill="random">
<path d="${bezlissajous(a,b)}Z"
transform="${`scale(${width}) translate(.5 .5) scale(0.48 -0.48)`}" />
</svg>`
Insert cell
lissajous = (a, b) =>
t => [Math.cos(a*t + phase_x), Math.cos(b*t + phase_y)]
Insert cell
bezlissajous = (a, b) =>
bezpts_to_svgpath(bezeval(lissajous(a, b), period(a, b), [-2, 2, -2, 2], tolerance)).replace(/\n/g,'')
Insert cell
transform = (i, j) =>
`translate(-${scale/2} -${scale/2}) scale(${scale}) translate(${i} ${j}) scale(0.45 -0.45)`
Insert cell
period = (a, b) => [0, 2 / gcd(a, b) * Math.PI]
Insert cell
gcd = (a, b) => {
while (b != 0) [a, b] = [b, a % b];
return a; }
Insert cell
tolerance = 0.0001
Insert cell
rows = [...Array(nrows+1).keys()].slice(1)
Insert cell
cols = [...Array(ncols+1).keys()].slice(1)
Insert cell
scale = width / ncols
Insert cell
height = scale * nrows
Insert cell
import {bezeval, bezpts_to_svgpath} from "@jrus/bezplot"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more