svelteplot 0.8.1-pr-302.0 → 0.9.0-pr-309.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
  [](https://app.netlify.com/projects/svelteplot/deploys)
|
|
4
4
|
|
|
5
|
-
SveltePlot is a visualization framework based on the [layered grammar of graphics](https://vita.had.co.nz/papers/layered-grammar.html) ideas. It's API is heavily inspired by [Observable Plot](https://github.com/observablehq/plot). Created by Gregor Aisch.
|
|
6
|
-
|
|
7
5
|
<img src="static/logo.svg" alt="SveltePlot logo" width="401" />
|
|
8
6
|
|
|
7
|
+
SveltePlot is a [Svelte](https://svelte.dev/)-native visualization framework based on the [layered grammar of graphics](https://vita.had.co.nz/papers/layered-grammar.html) principle. It's API is heavily inspired by [Observable Plot](https://github.com/observablehq/plot). Created by Gregor Aisch.
|
|
8
|
+
|
|
9
9
|
## Development
|
|
10
10
|
|
|
11
11
|
Clone the repo and install dependencies:
|
|
@@ -46,3 +46,4 @@ pnpm vi:report
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
To see the differences side by side you can open http://localhost:5173/\_\_vr/report.html
|
|
49
|
+
|
package/dist/constants.js
CHANGED
|
@@ -86,8 +86,15 @@ export const VALID_SCALE_TYPES = {
|
|
|
86
86
|
'quantile',
|
|
87
87
|
'quantize',
|
|
88
88
|
'threshold'
|
|
89
|
-
])
|
|
90
|
-
|
|
89
|
+
]),
|
|
90
|
+
symbol: new Set(['categorical', 'ordinal']),
|
|
91
|
+
opacity: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
92
|
+
r: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
93
|
+
length: new Set(['linear', 'log', 'symlog', 'sqrt', 'pow']),
|
|
94
|
+
fx: new Set(['band']),
|
|
95
|
+
fy: new Set(['band']),
|
|
96
|
+
// projection is a special type not mapping to a D3 scale
|
|
97
|
+
projection: new Set()
|
|
91
98
|
};
|
|
92
99
|
/**
|
|
93
100
|
* Map of all scaled channels
|
|
@@ -9,7 +9,7 @@ export declare function autoScale({ name, type, domain, scaleOptions, plotOption
|
|
|
9
9
|
plotHeight: number;
|
|
10
10
|
plotHasFilledDotMarks: boolean;
|
|
11
11
|
plotDefaults: PlotDefaults;
|
|
12
|
-
}):
|
|
12
|
+
}): (val: any) => any;
|
|
13
13
|
export declare function autoScaleColor({ type, domain, scaleOptions, plotOptions, plotWidth, plotHeight, plotHasFilledDotMarks, plotDefaults }: {
|
|
14
14
|
name: ScaleName;
|
|
15
15
|
type: ScaleType;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RawValue } from '../types/index.js';
|
|
2
|
-
type Setter = (v: any) => void;
|
|
3
2
|
/**
|
|
4
3
|
* Helper function to call a D3 "function class" while also calling
|
|
5
4
|
* property setter functions on the result.
|
|
6
5
|
*/
|
|
7
|
-
export default function (d3func: () =>
|
|
8
|
-
export {};
|
|
6
|
+
export default function <T extends object>(d3func: (...args: RawValue[]) => T, args?: RawValue[], props?: Record<string, RawValue>): T;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Helper function to call a D3 "function class" while also calling
|
|
3
3
|
* property setter functions on the result.
|
|
4
4
|
*/
|
|
5
|
-
export default function (d3func, args, props = {}) {
|
|
5
|
+
export default function (d3func, args = [], props = {}) {
|
|
6
6
|
const res = d3func(...args);
|
|
7
|
+
const resWithKeys = res;
|
|
7
8
|
for (const [key, val] of Object.entries(props)) {
|
|
8
|
-
|
|
9
|
+
const setter = resWithKeys[key];
|
|
10
|
+
if (typeof setter !== 'function')
|
|
9
11
|
throw new Error(`function ${key} does not exist`);
|
|
10
|
-
|
|
12
|
+
setter(val);
|
|
11
13
|
}
|
|
12
14
|
return res;
|
|
13
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-pr-309.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gregor Aisch",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
17
17
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
18
18
|
"lint": "prettier --check src && eslint src",
|
|
19
|
+
"lint:types": "tsc --noEmit",
|
|
19
20
|
"format": "prettier --write .",
|
|
20
21
|
"test:unit": "vitest",
|
|
21
22
|
"prepack": "npx svelte-package",
|