-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d859ff9
commit 3e49a27
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as Plot from "@observablehq/plot"; | ||
import * as d3 from "d3"; | ||
import {JSDOM} from "jsdom"; | ||
|
||
const dom = new JSDOM(``); | ||
|
||
export function makeBarChart(data, x, y) { | ||
|
||
// see https://stackoverflow.com/questions/74573576/how-to-use-observable-plot-in-nodejs | ||
// see https://github.com/observablehq/plot/discussions/847?sort=top | ||
|
||
let plot = Plot.plot({ | ||
x: { | ||
tickFormat: d3.format(",.1c"), | ||
label: "" | ||
}, | ||
y: { | ||
label: "" | ||
}, | ||
style: { | ||
fontSize: "14px", | ||
}, | ||
document: dom.window.document, | ||
marks: [ | ||
Plot.barY(data, {x: x, y: y, fill: "grey"}), | ||
Plot.ruleY([0]) | ||
] | ||
}); | ||
return plot.outerHTML; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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