Last active
May 25, 2023 22:49
Deno wrapper for using @observablehq/plot to generate SVG charts server-side
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parseHTML } from "https://esm.sh/linkedom@0.14.25"; | |
import * as ObservablePlot from "https://esm.sh/@observablehq/plot@0.6.7"; | |
// @ts-ignore: bad type | |
const { document } = parseHTML(`<!DOCTYPE html><html lang="en"></html>`); | |
export const Plot: typeof ObservablePlot = { | |
...ObservablePlot, | |
plot: (options?: ObservablePlot.PlotOptions) => { | |
const elt = ObservablePlot.plot({ document, ...options }); | |
elt.setAttribute("xmlns", "http://www.w3.org/2000/svg"); | |
elt.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"); | |
return elt.toString(); | |
}, | |
}; |
Author
cmoog
commented
May 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment