Public
Edited
Jun 30, 2023
Insert cell
Insert cell
weave = new Weave()
Insert cell
seedView = Inputs.form({
lat: Inputs.range([-90.0, 90.0], { label: 'Latitude' }),
lng: Inputs.range([0.0, 360.0], { label: 'Longitude' }),
prs: Inputs.range([1.0, 1000.0], { label: 'Pressure' }),
})
Insert cell
seed = settled(seedView)
Insert cell
trace = weave.tag`
return weave_braid_trace{
from="2017-01-01",
to="2017-01-08",
seeds={ ${seed} },
}`
Insert cell
vega({
width: 512,
height: 128,
datasets: {
trace: trace[0].points.map((d, i) => ({ ...d, i })),
},
layer: [
{ name: 'lat', lo: -90.0, hi: 90.0 },
{ name: 'lng', lo: 0.0, hi: 360.0 },
{ name: 'prs', lo: 1.0, hi: 1000.0 },
].map(({ name, lo, hi }) => ({
data: { name: 'trace' },
mark: { type: 'line' },
encoding: {
x: { field: 'sec', type: 'quantitative' },
y: { field: name, type: 'quantitative', scale: { domain: [lo, hi ] } },
},
})),
})
Insert cell
trace
X*
Y*
Color
Size
Facet X
Facet Y
Mark
Auto
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {viewroutine, ask, inspect, settled, vega} from "@player1537/utilities"
Insert cell
({
text:
(await FileAttachment("https __mothereff.in_lua-minifier.html").html())
.querySelector('script')
.textContent
})
Insert cell
luaMinifier.luamin.minify(`for z = 1, 10 do
for y = 1, 10 do
for x = 1, 10 do
if x ^ 2 + y ^ 2 == z ^ 2 then
print('found a Pythagorean triple:', x, y, z)
goto done
end
end
end
end
::done::`)
Insert cell
window.luamin
Insert cell
luaMinifier = {
const html = await FileAttachment("https __mothereff.in_lua-minifier.html").html();
const script = html.querySelector('script');
const text = script.textContent;
const blob = new Blob([text], { type: 'text/javascript' });
const url = URL.createObjectURL(blob);

const proxy = htl.html`<iframe style="display:none">`;
document.body.appendChild(proxy)
invalidation.then(() => proxy.remove())

const before = new Set();
for (const key of Object.keys(proxy.contentWindow)) {
before.add(key);
}

await new Promise((resolve) => {
proxy.contentWindow.__resolve = resolve;
proxy.contentWindow.document.write(`
<script src="${url}"></script>
<script>__resolve()</script>
`);
});
delete proxy.contentWindow['__resolve'];

const after = new Set();
for (const key of Object.keys(proxy.contentWindow)) {
if (before.has(key)) continue;
after.add(key);
}

const lib = {};
for (const key of after) {
const value = proxy.contentWindow[key];
delete proxy.contentWindow[key];
lib[key] = value;
}

return lib;
}
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