Set up and document uPlot
This commit is contained in:
parent
8496c557f6
commit
9caf664b10
7 changed files with 6909 additions and 0 deletions
13
README.md
13
README.md
|
|
@ -52,3 +52,16 @@ should use the dev database instead of `.sqlx/`, but only in your IDE.
|
||||||
|
|
||||||
[sqlx]: https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md
|
[sqlx]: https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md
|
||||||
[ra-opt]: https://rust-analyzer.github.io/manual.html#rust-analyzer.check.extraEnv
|
[ra-opt]: https://rust-analyzer.github.io/manual.html#rust-analyzer.check.extraEnv
|
||||||
|
|
||||||
|
### uPlot
|
||||||
|
|
||||||
|
For displaying graphs, the [uPlot library][uplot] is used. Because this is the
|
||||||
|
only dependency on the JS side, I decided not to use a package manager and
|
||||||
|
instead just add the library files directly.
|
||||||
|
|
||||||
|
To update the uPlot files, run `./meta/update_uplot`. This will download the
|
||||||
|
required files from uPlot's master. The `uPlot.d.ts` file's export statement is
|
||||||
|
patched to resemble the one in `uPlot.js`. This way I don't have to enable
|
||||||
|
`esModuleInterop` in my `tsconfig.json`.
|
||||||
|
|
||||||
|
[uplot]: https://github.com/leeoniya/uPlot/
|
||||||
|
|
|
||||||
5
meta/update_uplot
Executable file
5
meta/update_uplot
Executable file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
curl 'https://raw.githubusercontent.com/leeoniya/uPlot/master/dist/uPlot.d.ts' -o scripts/uPlot.d.ts
|
||||||
|
curl 'https://raw.githubusercontent.com/leeoniya/uPlot/master/dist/uPlot.esm.js' -o scripts/uPlot.js
|
||||||
|
curl 'https://raw.githubusercontent.com/leeoniya/uPlot/master/dist/uPlot.min.css' -o static/uPlot.css
|
||||||
|
sed -i 's/^export = uPlot;$/export { uPlot as default };/' scripts/uPlot.d.ts
|
||||||
7
scripts/graph.ts
Normal file
7
scripts/graph.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
import uPlot from "./uPlot";
|
||||||
|
|
||||||
|
let plot = new uPlot({
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
series: [],
|
||||||
|
});
|
||||||
1149
scripts/uPlot.d.ts
vendored
Normal file
1149
scripts/uPlot.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
5733
scripts/uPlot.js
Normal file
5733
scripts/uPlot.js
Normal file
File diff suppressed because it is too large
Load diff
1
static/uPlot.css
Normal file
1
static/uPlot.css
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.uplot, .uplot *, .uplot *::before, .uplot *::after {box-sizing: border-box;}.uplot {font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";line-height: 1.5;width: min-content;}.u-title {text-align: center;font-size: 18px;font-weight: bold;}.u-wrap {position: relative;user-select: none;}.u-over, .u-under {position: absolute;}.u-under {overflow: hidden;}.uplot canvas {display: block;position: relative;width: 100%;height: 100%;}.u-axis {position: absolute;}.u-legend {font-size: 14px;margin: auto;text-align: center;}.u-inline {display: block;}.u-inline * {display: inline-block;}.u-inline tr {margin-right: 16px;}.u-legend th {font-weight: 600;}.u-legend th > * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;}
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
"module": "ES2015",
|
"module": "ES2015",
|
||||||
"rootDir": "scripts",
|
"rootDir": "scripts",
|
||||||
"outDir": "target/static",
|
"outDir": "target/static",
|
||||||
|
"allowJs": true,
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
// TODO Source maps?
|
// TODO Source maps?
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue