svelteplot 0.0.1-alpha.0 → 0.0.1-alpha.2
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/dist/Plot.svelte +171 -0
- package/dist/Plot.svelte.d.ts +15 -0
- package/dist/classes/Channel.svelte.js +72 -0
- package/dist/classes/Mark.svelte.js +17 -0
- package/dist/classes/Plot.svelte.js +99 -0
- package/dist/contants.d.ts +3 -0
- package/dist/contants.js +40 -0
- package/dist/helpers/GroupMultiple.svelte +8 -0
- package/dist/helpers/GroupMultiple.svelte.d.ts +19 -0
- package/dist/helpers/autoTimeFormat.d.ts +2 -0
- package/dist/helpers/autoTimeFormat.js +10 -0
- package/dist/helpers/colors.d.ts +13 -0
- package/dist/helpers/colors.js +200 -0
- package/dist/helpers/createScale.d.ts +4 -0
- package/dist/helpers/createScale.js +47 -0
- package/dist/helpers/getBaseStyles.d.ts +2 -0
- package/dist/helpers/getBaseStyles.js +18 -0
- package/dist/helpers/getLogTicks.d.ts +1 -0
- package/dist/helpers/getLogTicks.js +57 -0
- package/dist/helpers/isDataRecord.d.ts +2 -0
- package/dist/helpers/isDataRecord.js +13 -0
- package/dist/helpers/mergeDeep.d.ts +5 -0
- package/dist/helpers/mergeDeep.js +26 -0
- package/dist/helpers/removeIdenticalLines.d.ts +1 -0
- package/dist/helpers/removeIdenticalLines.js +16 -0
- package/dist/helpers/resolveChannel.d.ts +2 -0
- package/dist/helpers/resolveChannel.js +28 -0
- package/dist/helpers/symbols.d.ts +5 -0
- package/dist/helpers/symbols.js +51 -0
- package/dist/helpers/typeChecks.d.ts +7 -0
- package/dist/helpers/typeChecks.js +21 -0
- package/dist/helpers/wrapArray.d.ts +2 -0
- package/dist/helpers/wrapArray.js +4 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/dist/marks/AxisX.svelte +101 -0
- package/dist/marks/AxisX.svelte.d.ts +17 -0
- package/dist/marks/AxisY.svelte +69 -0
- package/dist/marks/AxisY.svelte.d.ts +15 -0
- package/dist/marks/BaseMark.svelte +22 -0
- package/dist/marks/BaseMark.svelte.d.ts +19 -0
- package/dist/marks/ColorLegend.svelte +52 -0
- package/dist/marks/ColorLegend.svelte.d.ts +14 -0
- package/dist/marks/Dot.svelte +83 -0
- package/dist/marks/Dot.svelte.d.ts +15 -0
- package/dist/marks/DotX.svelte +5 -0
- package/dist/marks/DotX.svelte.d.ts +17 -0
- package/dist/marks/DotY.svelte +5 -0
- package/dist/marks/DotY.svelte.d.ts +17 -0
- package/dist/marks/Frame.svelte +37 -0
- package/dist/marks/Frame.svelte.d.ts +15 -0
- package/dist/marks/GridX.svelte +42 -0
- package/dist/marks/GridX.svelte.d.ts +19 -0
- package/dist/marks/GridY.svelte +31 -0
- package/dist/marks/GridY.svelte.d.ts +15 -0
- package/dist/marks/Line.svelte +49 -0
- package/dist/marks/Line.svelte.d.ts +15 -0
- package/dist/marks/LineX.svelte +10 -0
- package/dist/marks/LineX.svelte.d.ts +17 -0
- package/dist/marks/LineY.svelte +10 -0
- package/dist/marks/LineY.svelte.d.ts +17 -0
- package/dist/marks/RuleX.svelte +30 -0
- package/dist/marks/RuleX.svelte.d.ts +15 -0
- package/dist/marks/RuleY.svelte +31 -0
- package/dist/marks/RuleY.svelte.d.ts +15 -0
- package/dist/marks/SymbolLegend.svelte +50 -0
- package/dist/marks/SymbolLegend.svelte.d.ts +14 -0
- package/dist/types.d.ts +188 -0
- package/dist/types.js +1 -0
- package/package.json +4 -2
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { CHANNEL_TYPES } from './contants';
|
|
3
|
+
import type { Plot } from './classes/Plot.svelte';
|
|
4
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
5
|
+
export type Datasets = {
|
|
6
|
+
aapl: {
|
|
7
|
+
Date: Date;
|
|
8
|
+
High: number;
|
|
9
|
+
Low: number;
|
|
10
|
+
Open: number;
|
|
11
|
+
Close: number;
|
|
12
|
+
'Adj Close': number;
|
|
13
|
+
}[];
|
|
14
|
+
cars: {
|
|
15
|
+
name: string;
|
|
16
|
+
'economy (mpg)': number;
|
|
17
|
+
cylinders: number;
|
|
18
|
+
'displacement (cc)': number;
|
|
19
|
+
'power (hp)': number;
|
|
20
|
+
'weight (lb)': number;
|
|
21
|
+
'0-60 mph (s)': number;
|
|
22
|
+
year: number;
|
|
23
|
+
}[];
|
|
24
|
+
penguins: {
|
|
25
|
+
species: string;
|
|
26
|
+
island: string;
|
|
27
|
+
culmen_length_mm: number;
|
|
28
|
+
culmen_depth_mm: number;
|
|
29
|
+
flipper_length_mm: number;
|
|
30
|
+
body_mass_g: number;
|
|
31
|
+
sex: string;
|
|
32
|
+
}[];
|
|
33
|
+
};
|
|
34
|
+
export type AxisXAnchor = 'bottom' | 'top' | 'both';
|
|
35
|
+
export type AxisYAnchor = 'left' | 'right' | 'both';
|
|
36
|
+
export type PositionChannelOptions = Partial<{
|
|
37
|
+
label?: string | null;
|
|
38
|
+
domain?: [number, number] | null;
|
|
39
|
+
grid?: boolean;
|
|
40
|
+
ticks?: RawValue[];
|
|
41
|
+
tickSpacing?: number;
|
|
42
|
+
log?: boolean;
|
|
43
|
+
reverse?: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
export type PlotProps = {
|
|
46
|
+
height?: number | 'auto';
|
|
47
|
+
marginTop?: number;
|
|
48
|
+
marginBottom?: number;
|
|
49
|
+
marginLeft?: number;
|
|
50
|
+
marginRight?: number;
|
|
51
|
+
maxWidth?: string;
|
|
52
|
+
inset?: number;
|
|
53
|
+
grid?: boolean;
|
|
54
|
+
frame?: boolean;
|
|
55
|
+
title?: string;
|
|
56
|
+
subtitle?: string;
|
|
57
|
+
caption?: string;
|
|
58
|
+
onmousemove?: MouseEventHandler<SVGElement>;
|
|
59
|
+
header?: Snippet<Plot>;
|
|
60
|
+
footer?: Snippet<Plot>;
|
|
61
|
+
children?: Snippet<Plot>;
|
|
62
|
+
overlay?: Snippet<Plot>;
|
|
63
|
+
radius?: {
|
|
64
|
+
range?: [number, number];
|
|
65
|
+
};
|
|
66
|
+
x?: PositionChannelOptions & {
|
|
67
|
+
axis?: AxisXAnchor | {
|
|
68
|
+
anchor: AxisXAnchor;
|
|
69
|
+
tickSpacing: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
y?: PositionChannelOptions & {
|
|
73
|
+
axis?: AxisYAnchor | {
|
|
74
|
+
anchor: AxisYAnchor;
|
|
75
|
+
tickSpacing: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
symbol?: {
|
|
79
|
+
range?: string[];
|
|
80
|
+
legend?: boolean;
|
|
81
|
+
} | null;
|
|
82
|
+
color?: {
|
|
83
|
+
scheme?: ColorScheme | string[];
|
|
84
|
+
legend?: boolean;
|
|
85
|
+
} | null;
|
|
86
|
+
};
|
|
87
|
+
export type Margins = {
|
|
88
|
+
top: number;
|
|
89
|
+
left: number;
|
|
90
|
+
bottom: number;
|
|
91
|
+
right: number;
|
|
92
|
+
};
|
|
93
|
+
export type GridProps = {
|
|
94
|
+
tickFormat?: (d: any) => string;
|
|
95
|
+
};
|
|
96
|
+
export type DataRecord = Record<string, RawValue>;
|
|
97
|
+
export type DataRow = DataRecord | RawValue | [number, number];
|
|
98
|
+
export type ChannelAccessor = RawValue | ((d: DataRow) => RawValue) | null;
|
|
99
|
+
export type RawValue = number | Date | boolean | string | null;
|
|
100
|
+
export type ChannelName = 'opacity' | 'color' | 'x' | 'y' | 'angle' | 'radius' | 'symbol' | 'width';
|
|
101
|
+
export type MarkStyleProps = 'strokeDasharray' | 'opacity' | 'fill' | 'fillOpacity' | 'fontSize' | 'stroke' | 'strokeWidth' | 'strokeOpacity' | 'x' | 'y' | 'angle' | 'radius' | 'symbol' | 'width';
|
|
102
|
+
export type MarkProps2 = 'x' | 'y' | 'r' | 'rotate' | 'symbol';
|
|
103
|
+
export type ValueOf<T> = T[keyof T];
|
|
104
|
+
export type ChannelType = ValueOf<typeof CHANNEL_TYPES>;
|
|
105
|
+
export interface MarkProps {
|
|
106
|
+
data: DataRow[];
|
|
107
|
+
}
|
|
108
|
+
export type BaseMarkProps = MarkProps & {
|
|
109
|
+
type: string;
|
|
110
|
+
channels: ChannelName[];
|
|
111
|
+
automatic: boolean;
|
|
112
|
+
};
|
|
113
|
+
export type BaseMarkStyleProps = {
|
|
114
|
+
fill?: ChannelAccessor;
|
|
115
|
+
stroke?: ChannelAccessor;
|
|
116
|
+
opacity?: ChannelAccessor;
|
|
117
|
+
fillOpacity?: ChannelAccessor;
|
|
118
|
+
strokeOpacity?: ChannelAccessor;
|
|
119
|
+
strokeWidth?: ChannelAccessor;
|
|
120
|
+
strokeDasharray?: ChannelAccessor;
|
|
121
|
+
};
|
|
122
|
+
export type FrameProps = BaseMarkStyleProps;
|
|
123
|
+
export type DotMarkProps = MarkProps & BaseMarkStyleProps & {
|
|
124
|
+
data: DataRow[];
|
|
125
|
+
x?: ChannelAccessor;
|
|
126
|
+
y?: ChannelAccessor;
|
|
127
|
+
r?: ChannelAccessor;
|
|
128
|
+
rotate?: ChannelAccessor;
|
|
129
|
+
symbol?: ChannelAccessor;
|
|
130
|
+
};
|
|
131
|
+
export type LineMarkProps = MarkProps & BaseMarkStyleProps & {
|
|
132
|
+
data: DataRow[];
|
|
133
|
+
x?: ChannelAccessor;
|
|
134
|
+
y?: ChannelAccessor;
|
|
135
|
+
z?: ChannelAccessor;
|
|
136
|
+
};
|
|
137
|
+
export type GridOptions = {
|
|
138
|
+
ticks?: RawValue[];
|
|
139
|
+
strokeDasharray?: ChannelAccessor;
|
|
140
|
+
stroke?: ChannelAccessor;
|
|
141
|
+
strokeWidth?: ChannelAccessor;
|
|
142
|
+
};
|
|
143
|
+
export type GridXMarkProps = Partial<MarkProps> & GridOptions & {
|
|
144
|
+
y1?: ChannelAccessor;
|
|
145
|
+
y2?: ChannelAccessor;
|
|
146
|
+
automatic?: boolean;
|
|
147
|
+
};
|
|
148
|
+
export type GridYMarkProps = Partial<MarkProps> & GridOptions & {
|
|
149
|
+
x1?: ChannelAccessor;
|
|
150
|
+
x2?: ChannelAccessor;
|
|
151
|
+
automatic?: boolean;
|
|
152
|
+
};
|
|
153
|
+
export type AxisMarkOptions = {
|
|
154
|
+
ticks?: RawValue[];
|
|
155
|
+
automatic?: boolean;
|
|
156
|
+
tickSize?: number;
|
|
157
|
+
tickPadding?: number;
|
|
158
|
+
tickFormat?: ((d: RawValue) => string) | string;
|
|
159
|
+
tickFontSize?: ChannelAccessor;
|
|
160
|
+
title?: string;
|
|
161
|
+
stroke?: ChannelAccessor;
|
|
162
|
+
fill?: ChannelAccessor;
|
|
163
|
+
};
|
|
164
|
+
export type AxisXMarkProps = AxisMarkOptions & {
|
|
165
|
+
anchor?: 'top' | 'bottom';
|
|
166
|
+
};
|
|
167
|
+
export type AxisYMarkProps = AxisMarkOptions & {
|
|
168
|
+
anchor?: 'left' | 'right';
|
|
169
|
+
};
|
|
170
|
+
type RuleMarkProps = {
|
|
171
|
+
stroke?: ChannelAccessor;
|
|
172
|
+
opacity?: ChannelAccessor;
|
|
173
|
+
strokeOpacity?: ChannelAccessor;
|
|
174
|
+
strokeDasharray?: ChannelAccessor;
|
|
175
|
+
strokeWidth?: ChannelAccessor;
|
|
176
|
+
};
|
|
177
|
+
export type RuleXMarkProps = MarkProps & RuleMarkProps & {
|
|
178
|
+
x?: ChannelAccessor;
|
|
179
|
+
y1?: ChannelAccessor;
|
|
180
|
+
y2?: ChannelAccessor;
|
|
181
|
+
};
|
|
182
|
+
export type RuleYMarkProps = MarkProps & RuleMarkProps & {
|
|
183
|
+
y?: ChannelAccessor;
|
|
184
|
+
x1?: ChannelAccessor;
|
|
185
|
+
x2?: ChannelAccessor;
|
|
186
|
+
};
|
|
187
|
+
export type ColorScheme = 'brbg' | 'prgn' | 'piyg' | 'puor' | 'rdbu' | 'rdgy' | 'rdylbu' | 'rdylgn' | 'spectral' | 'burd' | 'buylrd' | 'blues' | 'greens' | 'greys' | 'oranges' | 'purples' | 'reds' | 'turbo' | 'viridis' | 'magma' | 'inferno' | 'plasma' | 'cividis' | 'cubehelix' | 'warm' | 'cool' | 'bugn' | 'bupu' | 'gnbu' | 'orrd' | 'pubu' | 'pubugn' | 'purd' | 'rdpu' | 'ylgn' | 'ylgnbu' | 'ylorbr' | 'ylorrd' | 'rainbow' | 'sinebow' | 'accent' | 'category10' | 'dark2' | 'paired' | 'pastel1' | 'pastel2' | 'set1' | 'set2' | 'set3' | 'tableau10';
|
|
188
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"lint": "prettier --check . && eslint .",
|
|
12
12
|
"format": "prettier --write .",
|
|
13
13
|
"test:integration": "playwright test",
|
|
14
|
-
"test:unit": "vitest"
|
|
14
|
+
"test:unit": "vitest",
|
|
15
|
+
"prepack": "npx svelte-package"
|
|
15
16
|
},
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"types": "./dist/index.d.ts",
|
|
61
62
|
"type": "module",
|
|
62
63
|
"dependencies": {
|
|
64
|
+
"@sveltejs/package": "^2.2.3",
|
|
63
65
|
"@types/d3-array": "^3.2.1",
|
|
64
66
|
"@types/d3-scale": "^4.0.8",
|
|
65
67
|
"@types/underscore": "^1.11.15",
|