Public
HTTP
Forked from fil/beckerBarley
stevekrouse-plotlinkedomsrrexample.web.val.run
June 11, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import * as Plot from "npm:@observablehq/plot@0.6.14";
import { d3 } from "npm:d3@7";
import { parseHTML } from "npm:linkedom@0.15";
export default async function() {
const document = parseHTML("<a>").document;
const chart = Plot.plot({
document,
marks: [
Plot.rectY({ length: 10000 }, Plot.binX({ y: "count" }, { x: Math.random })),
],
});
return new Response(
`${chart}`.replace(
/^<svg /,
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" ",
),
{ headers: { "Content-Type": "image/svg+xml" } },
);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 11, 2024