svelteplot 0.0.1-alpha.9 → 0.1.3-next.12

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.
Files changed (251) hide show
  1. package/LICENSE.md +5 -0
  2. package/README.md +3 -35
  3. package/dist/Mark.svelte +292 -0
  4. package/dist/Mark.svelte.d.ts +22 -0
  5. package/dist/Plot.svelte +148 -156
  6. package/dist/Plot.svelte.d.ts +15 -15
  7. package/dist/constants.d.ts +15 -0
  8. package/dist/constants.js +110 -0
  9. package/dist/core/Facet.svelte +59 -0
  10. package/dist/core/Facet.svelte.d.ts +18 -0
  11. package/dist/core/FacetAxes.svelte +66 -0
  12. package/dist/core/FacetAxes.svelte.d.ts +4 -0
  13. package/dist/core/FacetGrid.svelte +86 -0
  14. package/dist/core/FacetGrid.svelte.d.ts +13 -0
  15. package/dist/core/Plot.svelte +568 -0
  16. package/dist/core/Plot.svelte.d.ts +14 -0
  17. package/dist/helpers/arrowPath.d.ts +14 -0
  18. package/dist/helpers/arrowPath.js +129 -0
  19. package/dist/helpers/autoProjection.d.ts +19 -0
  20. package/dist/helpers/autoProjection.js +87 -0
  21. package/dist/helpers/autoScales.d.ts +23 -0
  22. package/dist/helpers/autoScales.js +203 -0
  23. package/dist/helpers/autoTicks.d.ts +3 -0
  24. package/dist/helpers/autoTicks.js +40 -0
  25. package/dist/helpers/autoTimeFormat.d.ts +2 -2
  26. package/dist/helpers/autoTimeFormat.js +34 -5
  27. package/dist/helpers/callWithProps.d.ts +8 -0
  28. package/dist/helpers/callWithProps.js +13 -0
  29. package/dist/helpers/colors.js +17 -2
  30. package/dist/helpers/curves.d.ts +3 -0
  31. package/dist/helpers/curves.js +42 -0
  32. package/dist/helpers/data.d.ts +9 -0
  33. package/dist/helpers/data.js +16 -0
  34. package/dist/helpers/facets.d.ts +12 -0
  35. package/dist/helpers/facets.js +49 -0
  36. package/dist/helpers/formats.d.ts +3 -0
  37. package/dist/helpers/formats.js +3 -0
  38. package/dist/helpers/getBaseStyles.d.ts +7 -2
  39. package/dist/helpers/getBaseStyles.js +34 -10
  40. package/dist/helpers/getLogTicks.js +5 -5
  41. package/dist/helpers/group.d.ts +6 -0
  42. package/dist/helpers/group.js +53 -0
  43. package/dist/helpers/index.d.ts +18 -0
  44. package/dist/helpers/index.js +55 -0
  45. package/dist/helpers/isRawValue.d.ts +2 -0
  46. package/dist/helpers/isRawValue.js +5 -0
  47. package/dist/helpers/isValid.d.ts +6 -0
  48. package/dist/helpers/isValid.js +6 -0
  49. package/dist/helpers/math.d.ts +19 -0
  50. package/dist/helpers/math.js +116 -0
  51. package/dist/helpers/mergeDeep.d.ts +1 -1
  52. package/dist/helpers/noise.d.ts +1 -0
  53. package/dist/helpers/noise.js +72 -0
  54. package/dist/helpers/projection.d.ts +33 -0
  55. package/dist/helpers/projection.js +100 -0
  56. package/dist/helpers/reduce.d.ts +10 -0
  57. package/dist/helpers/reduce.js +85 -0
  58. package/dist/helpers/regressionLoess.d.ts +12 -0
  59. package/dist/helpers/regressionLoess.js +47 -0
  60. package/dist/helpers/removeIdenticalLines.d.ts +8 -1
  61. package/dist/helpers/removeIdenticalLines.js +14 -7
  62. package/dist/helpers/resolve.d.ts +21 -0
  63. package/dist/helpers/resolve.js +156 -0
  64. package/dist/helpers/roundedRect.d.ts +9 -0
  65. package/dist/helpers/roundedRect.js +31 -0
  66. package/dist/helpers/scales.d.ts +42 -0
  67. package/dist/helpers/scales.js +311 -0
  68. package/dist/helpers/time.d.ts +6 -0
  69. package/dist/helpers/time.js +282 -0
  70. package/dist/helpers/typeChecks.d.ts +8 -5
  71. package/dist/helpers/typeChecks.js +27 -6
  72. package/dist/index.d.ts +49 -1
  73. package/dist/index.js +53 -2
  74. package/dist/marks/Area.svelte +146 -0
  75. package/dist/marks/Area.svelte.d.ts +30 -0
  76. package/dist/marks/AreaX.svelte +27 -0
  77. package/dist/marks/AreaX.svelte.d.ts +12 -0
  78. package/dist/marks/AreaY.svelte +38 -0
  79. package/dist/marks/AreaY.svelte.d.ts +19 -0
  80. package/dist/marks/Arrow.svelte +139 -0
  81. package/dist/marks/Arrow.svelte.d.ts +44 -0
  82. package/dist/marks/AxisX.svelte +198 -93
  83. package/dist/marks/AxisX.svelte.d.ts +17 -16
  84. package/dist/marks/AxisY.svelte +176 -62
  85. package/dist/marks/AxisY.svelte.d.ts +17 -14
  86. package/dist/marks/BarX.svelte +93 -0
  87. package/dist/marks/BarX.svelte.d.ts +4 -0
  88. package/dist/marks/BarY.svelte +103 -0
  89. package/dist/marks/BarY.svelte.d.ts +25 -0
  90. package/dist/marks/BollingerX.svelte +44 -0
  91. package/dist/marks/BollingerX.svelte.d.ts +18 -0
  92. package/dist/marks/BollingerY.svelte +39 -0
  93. package/dist/marks/BollingerY.svelte.d.ts +18 -0
  94. package/dist/marks/BoxX.svelte +89 -0
  95. package/dist/marks/BoxX.svelte.d.ts +4 -0
  96. package/dist/marks/BoxY.svelte +110 -0
  97. package/dist/marks/BoxY.svelte.d.ts +29 -0
  98. package/dist/marks/Cell.svelte +110 -0
  99. package/dist/marks/Cell.svelte.d.ts +16 -0
  100. package/dist/marks/CellX.svelte +24 -0
  101. package/dist/marks/CellX.svelte.d.ts +3 -0
  102. package/dist/marks/CellY.svelte +24 -0
  103. package/dist/marks/CellY.svelte.d.ts +3 -0
  104. package/dist/marks/ColorLegend.svelte +148 -27
  105. package/dist/marks/ColorLegend.svelte.d.ts +12 -13
  106. package/dist/marks/CustomMark.svelte +43 -0
  107. package/dist/marks/CustomMark.svelte.d.ts +16 -0
  108. package/dist/marks/CustomMarkHTML.svelte +103 -0
  109. package/dist/marks/CustomMarkHTML.svelte.d.ts +17 -0
  110. package/dist/marks/DifferenceY.svelte +144 -0
  111. package/dist/marks/DifferenceY.svelte.d.ts +30 -0
  112. package/dist/marks/Dot.svelte +128 -73
  113. package/dist/marks/Dot.svelte.d.ts +24 -14
  114. package/dist/marks/DotX.svelte +15 -3
  115. package/dist/marks/DotX.svelte.d.ts +8 -16
  116. package/dist/marks/DotY.svelte +8 -3
  117. package/dist/marks/DotY.svelte.d.ts +5 -17
  118. package/dist/marks/Frame.svelte +39 -31
  119. package/dist/marks/Frame.svelte.d.ts +7 -14
  120. package/dist/marks/Geo.svelte +102 -0
  121. package/dist/marks/Geo.svelte.d.ts +10 -0
  122. package/dist/marks/Graticule.svelte +28 -0
  123. package/dist/marks/Graticule.svelte.d.ts +9 -0
  124. package/dist/marks/GridX.svelte +67 -36
  125. package/dist/marks/GridX.svelte.d.ts +7 -18
  126. package/dist/marks/GridY.svelte +64 -25
  127. package/dist/marks/GridY.svelte.d.ts +7 -14
  128. package/dist/marks/HTMLTooltip.svelte +91 -0
  129. package/dist/marks/HTMLTooltip.svelte.d.ts +11 -0
  130. package/dist/marks/Line.svelte +219 -58
  131. package/dist/marks/Line.svelte.d.ts +30 -14
  132. package/dist/marks/LineX.svelte +8 -8
  133. package/dist/marks/LineX.svelte.d.ts +4 -17
  134. package/dist/marks/LineY.svelte +7 -8
  135. package/dist/marks/LineY.svelte.d.ts +4 -17
  136. package/dist/marks/Link.svelte +180 -0
  137. package/dist/marks/Link.svelte.d.ts +21 -0
  138. package/dist/marks/Pointer.svelte +126 -0
  139. package/dist/marks/Pointer.svelte.d.ts +23 -0
  140. package/dist/marks/Rect.svelte +103 -0
  141. package/dist/marks/Rect.svelte.d.ts +15 -0
  142. package/dist/marks/RectX.svelte +33 -0
  143. package/dist/marks/RectX.svelte.d.ts +15 -0
  144. package/dist/marks/RectY.svelte +33 -0
  145. package/dist/marks/RectY.svelte.d.ts +15 -0
  146. package/dist/marks/RegressionX.svelte +26 -0
  147. package/dist/marks/RegressionX.svelte.d.ts +4 -0
  148. package/dist/marks/RegressionY.svelte +26 -0
  149. package/dist/marks/RegressionY.svelte.d.ts +4 -0
  150. package/dist/marks/RuleX.svelte +52 -28
  151. package/dist/marks/RuleX.svelte.d.ts +14 -14
  152. package/dist/marks/RuleY.svelte +52 -28
  153. package/dist/marks/RuleY.svelte.d.ts +14 -14
  154. package/dist/marks/Sphere.svelte +8 -0
  155. package/dist/marks/Sphere.svelte.d.ts +51 -0
  156. package/dist/marks/Spike.svelte +15 -0
  157. package/dist/marks/Spike.svelte.d.ts +4 -0
  158. package/dist/marks/SymbolLegend.svelte +27 -12
  159. package/dist/marks/SymbolLegend.svelte.d.ts +8 -14
  160. package/dist/marks/Text.svelte +189 -0
  161. package/dist/marks/Text.svelte.d.ts +26 -0
  162. package/dist/marks/TickX.svelte +89 -0
  163. package/dist/marks/TickX.svelte.d.ts +22 -0
  164. package/dist/marks/TickY.svelte +90 -0
  165. package/dist/marks/TickY.svelte.d.ts +22 -0
  166. package/dist/marks/Vector.svelte +219 -0
  167. package/dist/marks/Vector.svelte.d.ts +31 -0
  168. package/dist/marks/helpers/BaseAxisX.svelte +210 -0
  169. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +24 -0
  170. package/dist/marks/helpers/BaseAxisY.svelte +187 -0
  171. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +23 -0
  172. package/dist/marks/helpers/CanvasLayer.svelte +38 -0
  173. package/dist/marks/helpers/CanvasLayer.svelte.d.ts +13 -0
  174. package/dist/marks/helpers/DotCanvas.svelte +184 -0
  175. package/dist/marks/helpers/DotCanvas.svelte.d.ts +11 -0
  176. package/dist/marks/helpers/GeoCanvas.svelte +165 -0
  177. package/dist/marks/helpers/GeoCanvas.svelte.d.ts +13 -0
  178. package/dist/marks/helpers/GroupMultiple.svelte +17 -0
  179. package/dist/marks/helpers/GroupMultiple.svelte.d.ts +9 -0
  180. package/dist/marks/helpers/Marker.svelte +93 -0
  181. package/dist/marks/helpers/Marker.svelte.d.ts +10 -0
  182. package/dist/marks/helpers/MarkerPath.svelte +141 -0
  183. package/dist/marks/helpers/MarkerPath.svelte.d.ts +44 -0
  184. package/dist/marks/helpers/Regression.svelte +174 -0
  185. package/dist/marks/helpers/Regression.svelte.d.ts +26 -0
  186. package/dist/marks/helpers/events.d.ts +8 -0
  187. package/dist/marks/helpers/events.js +74 -0
  188. package/dist/transforms/bin.d.ts +51 -0
  189. package/dist/transforms/bin.js +171 -0
  190. package/dist/transforms/bollinger.d.ts +21 -0
  191. package/dist/transforms/bollinger.js +53 -0
  192. package/dist/transforms/centroid.d.ts +9 -0
  193. package/dist/transforms/centroid.js +13 -0
  194. package/dist/transforms/facet.d.ts +1 -0
  195. package/dist/transforms/facet.js +1 -0
  196. package/dist/transforms/filter.d.ts +2 -0
  197. package/dist/transforms/filter.js +8 -0
  198. package/dist/transforms/group.d.ts +66 -0
  199. package/dist/transforms/group.js +109 -0
  200. package/dist/transforms/interval.d.ts +11 -0
  201. package/dist/transforms/interval.js +34 -0
  202. package/dist/transforms/jitter.d.ts +1 -0
  203. package/dist/transforms/jitter.js +1 -0
  204. package/dist/transforms/map.d.ts +10 -0
  205. package/dist/transforms/map.js +89 -0
  206. package/dist/transforms/normalize.d.ts +9 -0
  207. package/dist/transforms/normalize.js +86 -0
  208. package/dist/transforms/recordize.d.ts +15 -0
  209. package/dist/transforms/recordize.js +78 -0
  210. package/dist/transforms/rename.d.ts +14 -0
  211. package/dist/transforms/rename.js +42 -0
  212. package/dist/transforms/select.d.ts +35 -0
  213. package/dist/transforms/select.js +55 -0
  214. package/dist/transforms/shift.d.ts +13 -0
  215. package/dist/transforms/shift.js +45 -0
  216. package/dist/transforms/sort.d.ts +28 -0
  217. package/dist/transforms/sort.js +66 -0
  218. package/dist/transforms/stack.d.ts +10 -0
  219. package/dist/transforms/stack.js +110 -0
  220. package/dist/transforms/window.d.ts +24 -0
  221. package/dist/transforms/window.js +73 -0
  222. package/dist/types.d.ts +625 -188
  223. package/dist/ui/Checkbox.svelte +6 -0
  224. package/dist/ui/Checkbox.svelte.d.ts +13 -0
  225. package/dist/ui/RadioInput.svelte +27 -0
  226. package/dist/ui/RadioInput.svelte.d.ts +9 -0
  227. package/dist/ui/Select.svelte +27 -0
  228. package/dist/ui/Select.svelte.d.ts +9 -0
  229. package/dist/ui/Slider.svelte +47 -0
  230. package/dist/ui/Slider.svelte.d.ts +11 -0
  231. package/dist/ui/Spiral.svelte +46 -0
  232. package/dist/ui/Spiral.svelte.d.ts +15 -0
  233. package/dist/ui/index.d.ts +4 -0
  234. package/dist/ui/index.js +4 -0
  235. package/package.json +81 -42
  236. package/LICENSE +0 -11
  237. package/dist/classes/Channel.svelte.js +0 -74
  238. package/dist/classes/Mark.svelte.js +0 -17
  239. package/dist/classes/Plot.svelte.js +0 -98
  240. package/dist/contants.d.ts +0 -3
  241. package/dist/contants.js +0 -40
  242. package/dist/helpers/GroupMultiple.svelte +0 -8
  243. package/dist/helpers/GroupMultiple.svelte.d.ts +0 -19
  244. package/dist/helpers/createScale.d.ts +0 -5
  245. package/dist/helpers/createScale.js +0 -57
  246. package/dist/helpers/resolveChannel.d.ts +0 -2
  247. package/dist/helpers/resolveChannel.js +0 -28
  248. package/dist/helpers/wrapArray.d.ts +0 -2
  249. package/dist/helpers/wrapArray.js +0 -4
  250. package/dist/marks/BaseMark.svelte +0 -22
  251. package/dist/marks/BaseMark.svelte.d.ts +0 -19
@@ -0,0 +1,6 @@
1
+ <script>
2
+ let { label, value = $bindable() } = $props();
3
+ </script>
4
+
5
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
6
+ <label><input type="checkbox" bind:checked={value} /> {@html label}</label>
@@ -0,0 +1,13 @@
1
+ export default Checkbox;
2
+ type Checkbox = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Checkbox: import("svelte").Component<{
7
+ label: any;
8
+ value?: any;
9
+ }, {}, "value">;
10
+ type $$ComponentProps = {
11
+ label: any;
12
+ value?: any;
13
+ };
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ let {
3
+ label = '',
4
+ value = $bindable(),
5
+ options,
6
+ format = (d) => d
7
+ }: {
8
+ label?: string;
9
+ value: string | number | undefined;
10
+ options: any[];
11
+ format?: (d: any) => string;
12
+ } = $props();
13
+
14
+ const randomId = (Math.random() * 1e7).toString(32);
15
+ </script>
16
+
17
+ <div style="display:inline-block">
18
+ {#if label}
19
+ <label for={randomId}>{label}:</label>
20
+ {/if}
21
+ {#each options as p}
22
+ <label>
23
+ <input type="radio" id={randomId} bind:group={value} value={p} />
24
+ {format(p)}
25
+ </label>
26
+ {/each}
27
+ </div>
@@ -0,0 +1,9 @@
1
+ type $$ComponentProps = {
2
+ label?: string;
3
+ value: string | number | undefined;
4
+ options: any[];
5
+ format?: (d: any) => string;
6
+ };
7
+ declare const RadioInput: import("svelte").Component<$$ComponentProps, {}, "value">;
8
+ type RadioInput = ReturnType<typeof RadioInput>;
9
+ export default RadioInput;
@@ -0,0 +1,27 @@
1
+ <script lang="ts">
2
+ let {
3
+ label = '',
4
+ value = $bindable(),
5
+ options,
6
+ format = (d) => d
7
+ }: {
8
+ label?: string;
9
+ value: string | number | undefined;
10
+ options: any[];
11
+ format?: (d: any) => string;
12
+ } = $props();
13
+ </script>
14
+
15
+ <label
16
+ >{label || ''}
17
+ <select bind:value>
18
+ {#each options as p}
19
+ <option value={p}>{format(p)}</option>
20
+ {/each}
21
+ </select></label>
22
+
23
+ <style>
24
+ label {
25
+ margin-right: 1em;
26
+ }
27
+ </style>
@@ -0,0 +1,9 @@
1
+ type $$ComponentProps = {
2
+ label?: string;
3
+ value: string | number | undefined;
4
+ options: any[];
5
+ format?: (d: any) => string;
6
+ };
7
+ declare const Select: import("svelte").Component<$$ComponentProps, {}, "value">;
8
+ type Select = ReturnType<typeof Select>;
9
+ export default Select;
@@ -0,0 +1,47 @@
1
+ <script lang="ts">
2
+ let {
3
+ label,
4
+ value = $bindable(),
5
+ min = 0,
6
+ max = 100,
7
+ step = 1,
8
+ type = 'range'
9
+ }: {
10
+ label: string;
11
+ type: 'range' | 'number';
12
+ value: number;
13
+ min?: number;
14
+ max?: number;
15
+ step?: number;
16
+ } = $props();
17
+ </script>
18
+
19
+ <label>
20
+ <span>{label}:</span>
21
+ {#if type === 'range'}
22
+ <input type="range" bind:value {min} {max} {step} />
23
+ <span class="value">({value})</span>{:else}
24
+ <input
25
+ type="number"
26
+ style:width={`${`${Math.max(Math.abs(min), Math.abs(max))}`.length}rem`}
27
+ bind:value
28
+ {min}
29
+ {max}
30
+ {step} />
31
+ {/if}
32
+ </label>
33
+
34
+ <style>
35
+ label {
36
+ display: inline-flex;
37
+ gap: 1ex;
38
+ margin-right: 1em;
39
+ }
40
+ .value {
41
+ opacity: 0.5;
42
+ }
43
+ input {
44
+ accent-color: var(--svp-accent);
45
+ width: 15ex;
46
+ }
47
+ </style>
@@ -0,0 +1,11 @@
1
+ type $$ComponentProps = {
2
+ label: string;
3
+ type: 'range' | 'number';
4
+ value: number;
5
+ min?: number;
6
+ max?: number;
7
+ step?: number;
8
+ };
9
+ declare const Slider: import("svelte").Component<$$ComponentProps, {}, "value">;
10
+ type Slider = ReturnType<typeof Slider>;
11
+ export default Slider;
@@ -0,0 +1,46 @@
1
+ <script>
2
+ let { numTurns = 4, finalRadius = 10, duration = 2, ...restProps } = $props();
3
+
4
+ const pathD = $derived.by(() => {
5
+ const numPoints = 100;
6
+ const k = finalRadius / (2 * Math.PI * numTurns);
7
+ const angleStep = (2 * Math.PI * numTurns) / numPoints;
8
+
9
+ const points = [];
10
+ for (let i = 0; i <= numPoints; i++) {
11
+ const t = i * angleStep;
12
+ const r = k * t;
13
+ const x = r * Math.cos(t);
14
+ const y = r * Math.sin(t);
15
+ points.push([x, y]);
16
+ }
17
+
18
+ let d = `M ${points[0][0].toFixed(2)},${points[0][1].toFixed(2)} `;
19
+ for (let i = 1; i < points.length; i++) {
20
+ d += `L ${points[i][0].toFixed(2)},${points[i][1].toFixed(2)} `;
21
+ }
22
+ return d.trim();
23
+ });
24
+ </script>
25
+
26
+ <path
27
+ d={pathD}
28
+ class="rotating"
29
+ style:animation-duration="{duration}s"
30
+ stroke="currentColor"
31
+ fill="none"
32
+ {...restProps} />
33
+
34
+ <style>
35
+ @keyframes rotating {
36
+ from {
37
+ transform: rotate(0deg);
38
+ }
39
+ to {
40
+ transform: rotate(360deg);
41
+ }
42
+ }
43
+ .rotating {
44
+ animation: rotating 2s linear infinite;
45
+ }
46
+ </style>
@@ -0,0 +1,15 @@
1
+ export default Spiral;
2
+ type Spiral = {
3
+ $on?(type: string, callback: (e: any) => void): () => void;
4
+ $set?(props: Partial<$$ComponentProps>): void;
5
+ };
6
+ declare const Spiral: import("svelte").Component<{
7
+ numTurns?: number;
8
+ finalRadius?: number;
9
+ duration?: number;
10
+ } & Record<string, any>, {}, "">;
11
+ type $$ComponentProps = {
12
+ numTurns?: number;
13
+ finalRadius?: number;
14
+ duration?: number;
15
+ } & Record<string, any>;
@@ -0,0 +1,4 @@
1
+ export { default as Slider } from './Slider.svelte';
2
+ export { default as Select } from './Select.svelte';
3
+ export { default as Checkbox } from './Checkbox.svelte';
4
+ export { default as RadioInput } from './RadioInput.svelte';
@@ -0,0 +1,4 @@
1
+ export { default as Slider } from './Slider.svelte';
2
+ export { default as Select } from './Select.svelte';
3
+ export { default as Checkbox } from './Checkbox.svelte';
4
+ export { default as RadioInput } from './RadioInput.svelte';
package/package.json CHANGED
@@ -1,78 +1,117 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.0.1-alpha.9",
3
+ "version": "0.1.3-next.12",
4
+ "license": "ISC",
5
+ "author": {
6
+ "name": "Gregor Aisch",
7
+ "email": "gka@users.noreply.github.com"
8
+ },
4
9
  "scripts": {
5
10
  "dev": "vite dev",
6
11
  "build": "vite build",
7
12
  "preview": "vite preview",
8
- "test": "npm run test:integration && npm run test:unit",
13
+ "test": "npm run test:unit",
9
14
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10
15
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11
- "lint": "prettier --check . && eslint .",
16
+ "lint": "prettier --check src && eslint src",
12
17
  "format": "prettier --write .",
13
- "test:integration": "playwright test",
14
18
  "test:unit": "vitest",
15
- "prepack": "npx svelte-package"
19
+ "prepack": "npx svelte-package",
20
+ "release-next": "npm version prerelease --preid next && npm publish && git push && git push --tags && sleep 1 && npm dist-tag add svelteplot@$(npm view . version) next",
21
+ "docs": "npm run build && cd build && rsync --recursive . vis4.net:svelteplot/alpha0/"
16
22
  },
17
23
  "exports": {
18
24
  ".": {
19
25
  "types": "./dist/index.d.ts",
20
26
  "svelte": "./dist/index.js"
27
+ },
28
+ "./*.js": {
29
+ "import": "./dist/*.js"
30
+ },
31
+ "./*.svelte": {
32
+ "import": "./dist/*.svelte"
33
+ },
34
+ "./core/*.svelte": {
35
+ "import": "./dist/core/*.svelte"
36
+ },
37
+ "./marks/*.svelte": {
38
+ "import": "./dist/marks/*.svelte"
21
39
  }
22
40
  },
41
+ "main": "./dist/index.js",
23
42
  "files": [
24
43
  "dist",
25
44
  "!dist/**/*.test.*",
26
45
  "!dist/**/*.spec.*"
27
46
  ],
28
- "peerDependencies": {
29
- "svelte": "^4.0.0"
30
- },
31
47
  "devDependencies": {
32
- "@playwright/test": "^1.40.1",
33
- "@sveltejs/adapter-auto": "^2.1.1",
34
- "@sveltejs/kit": "^1.27.6",
35
- "@types/chroma-js": "^2.4.3",
48
+ "@aitodotai/json-stringify-pretty-compact": "^1.3.0",
49
+ "@emotion/css": "^11.13.5",
50
+ "@sveltejs/adapter-auto": "^6.0.0",
51
+ "@sveltejs/adapter-static": "^3.0.8",
52
+ "@sveltejs/eslint-config": "^8.2.0",
53
+ "@sveltejs/kit": "^2.20.8",
54
+ "@sveltejs/package": "^2.3.11",
55
+ "@sveltejs/vite-plugin-svelte": "5.0.3",
56
+ "@sveltepress/theme-default": "^6.0.2",
57
+ "@sveltepress/twoslash": "^1.2.1",
58
+ "@sveltepress/vite": "^1.2.1",
59
+ "@testing-library/svelte": "^5.2.7",
60
+ "@types/d3-array": "^3.2.1",
61
+ "@types/d3-color": "^3.1.3",
62
+ "@types/d3-dsv": "^3.0.7",
63
+ "@types/d3-geo": "^3.1.0",
36
64
  "@types/d3-interpolate": "^3.0.4",
37
- "@types/d3-scale-chromatic": "^3.0.3",
38
- "@types/d3-shape": "^3.1.6",
39
- "@typescript-eslint/eslint-plugin": "^6.13.2",
40
- "@typescript-eslint/parser": "^6.13.2",
41
- "bulma": "^0.9.4",
65
+ "@types/d3-path": "^3.1.1",
66
+ "@types/d3-random": "^3.0.3",
67
+ "@types/d3-scale": "^4.0.9",
68
+ "@types/d3-scale-chromatic": "^3.1.0",
69
+ "@types/d3-shape": "^3.1.7",
70
+ "@typescript-eslint/eslint-plugin": "^8.31.1",
71
+ "@typescript-eslint/parser": "^8.31.1",
42
72
  "d3-dsv": "^3.0.1",
43
- "dayjs": "^1.11.10",
44
- "eslint": "^8.55.0",
45
- "eslint-config-prettier": "^9.1.0",
46
- "eslint-plugin-svelte": "^2.35.1",
47
- "highlight.js": "^11.9.0",
48
- "highlightjs-svelte": "^1.0.6",
49
- "prettier": "^3.1.0",
50
- "prettier-plugin-svelte": "^3.1.2",
51
- "sass": "^1.69.5",
52
- "svelte": "5.0.0-next.22",
53
- "svelte-check": "^3.6.2",
54
- "svelte-highlight": "^7.4.2",
55
- "tslib": "^2.6.2",
56
- "typescript": "^5.3.2",
57
- "vite": "^5.0.5",
58
- "vitest": "^1.0.1"
73
+ "d3-fetch": "^3.0.1",
74
+ "d3-force": "^3.0.0",
75
+ "eslint": "^9.26.0",
76
+ "eslint-config-prettier": "^10.1.2",
77
+ "eslint-plugin-svelte": "3.5.1",
78
+ "jsdom": "^26.1.0",
79
+ "prettier": "^3.5.3",
80
+ "prettier-plugin-svelte": "^3.3.3",
81
+ "remark-code-extra": "^1.0.1",
82
+ "remark-code-frontmatter": "^1.0.0",
83
+ "resize-observer-polyfill": "^1.5.1",
84
+ "sass": "^1.87.0",
85
+ "svelte-check": "^4.1.7",
86
+ "svelte-eslint-parser": "1.1.3",
87
+ "svelte-highlight": "^7.8.3",
88
+ "topojson-client": "^3.1.0",
89
+ "tslib": "^2.8.1",
90
+ "typedoc": "^0.28.4",
91
+ "typedoc-plugin-markdown": "^4.6.3",
92
+ "typescript": "^5.8.3",
93
+ "vite": "^6.3.4",
94
+ "vitest": "^3.1.2"
59
95
  },
60
- "svelte": "./dist/index.js",
61
96
  "types": "./dist/index.d.ts",
62
97
  "type": "module",
63
98
  "dependencies": {
64
- "@sveltejs/package": "^2.2.3",
65
- "@types/d3-array": "^3.2.1",
66
- "@types/d3-scale": "^4.0.8",
67
- "@types/underscore": "^1.11.15",
68
- "chroma-js": "^2.4.2",
69
99
  "d3-array": "^3.2.4",
100
+ "d3-color": "^3.1.0",
101
+ "d3-format": "^3.1.0",
102
+ "d3-geo": "^3.1.1",
70
103
  "d3-interpolate": "^3.0.1",
104
+ "d3-path": "^3.1.0",
105
+ "d3-quadtree": "^3.0.1",
106
+ "d3-random": "^3.0.1",
107
+ "d3-regression": "^1.3.10",
71
108
  "d3-scale": "^4.0.2",
72
- "d3-scale-chromatic": "^3.0.0",
109
+ "d3-scale-chromatic": "^3.1.0",
73
110
  "d3-shape": "^3.2.0",
74
- "d3-time-format": "^4.1.0",
111
+ "d3-time": "^3.1.0",
112
+ "es-toolkit": "^1.37.2",
113
+ "fast-equals": "^5.2.2",
75
114
  "merge-deep": "^3.0.3",
76
- "underscore": "^1.13.6"
115
+ "svelte": "5.28.2"
77
116
  }
78
117
  }
package/LICENSE DELETED
@@ -1,11 +0,0 @@
1
- Copyright 2023, Gregor Aisch
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,74 +0,0 @@
1
- import resolveChannel from '../helpers/resolveChannel.js';
2
- import { extent } from 'd3-array';
3
- import { MARK_PROP_CHANNEL } from '../contants.js';
4
- import { isBooleanOrNull, isColorOrNull, isDateOrNull, isNumberOrNull, isStringOrNull } from '../helpers/typeChecks.js';
5
- import { uniq } from 'underscore';
6
- export class Channel {
7
- name = undefined;
8
- plot = undefined;
9
- constructor(name, plot) {
10
- this.name = name;
11
- this.plot = plot;
12
- }
13
- // readonly type: ChannelType = CHANNEL_TYPES.position;
14
- // all marks that have this channel
15
- marks = $derived(this.plot?.marks ?? []);
16
- forceDomain = $derived(this.plot && (this.name === 'x' || this.name === 'y')
17
- ? this.plot.options[this.name]?.domain || null
18
- : null);
19
- possibleProps = $derived(Object.entries(MARK_PROP_CHANNEL)
20
- .filter(([, channel]) => channel === this.name)
21
- .map(([prop]) => prop));
22
- activeMarks = $derived(this.marks.filter((mark) => mark.channels.has(this.name) && this.possibleProps.find((prop) => mark.props[prop])));
23
- manualActiveMarks = $derived(this.activeMarks.filter((mark) => !mark.automatic));
24
- autoTitle = $derived(this.manualActiveMarks.length === 1 &&
25
- typeof this.manualActiveMarks[0].props?.[this.name] === 'string'
26
- ? this.manualActiveMarks[0].props?.[this.name]
27
- : null);
28
- uniqueMarkProps = $derived(uniq(this.manualActiveMarks
29
- .map((mark) => this.possibleProps
30
- .filter((prop) => mark.props[prop])
31
- .map((prop) => mark.props[prop]))
32
- .flat(2)));
33
- dataValues = $derived([
34
- ...this.activeMarks
35
- // only check marks with data
36
- .filter((mark) => mark.props.data.length)
37
- .map((mark) => this.possibleProps.map((prop) => mark.props.data.map((row) => resolveChannel(this.name, row, mark.props[prop]))))
38
- .flat(3)
39
- .filter((d) => d != null),
40
- ...(this.forceDomain || [])
41
- ]);
42
- valueType = $derived(this.dataValues.every((v) => v == null)
43
- ? 'null'
44
- : this.dataValues.every(isColorOrNull)
45
- ? 'color'
46
- : this.dataValues.every(isBooleanOrNull)
47
- ? 'boolean'
48
- : this.dataValues.every(isStringOrNull)
49
- ? 'text'
50
- : this.dataValues.every(isNumberOrNull)
51
- ? 'number'
52
- : this.dataValues.every(isDateOrNull)
53
- ? 'date'
54
- : 'mixed');
55
- domain = $derived(!this.dataValues.length
56
- ? [0, 1]
57
- : this.valueType === 'boolean' ||
58
- this.valueType === 'text' ||
59
- this.valueType === 'color'
60
- ? uniq(this.dataValues)
61
- : extent(this.dataValues));
62
- scaleType = $derived(this.name === 'radius'
63
- ? 'sqrt'
64
- : this.valueType === 'date'
65
- ? 'time'
66
- : this.valueType === 'number'
67
- ? 'linear'
68
- : this.valueType === 'text'
69
- ? 'band'
70
- : this.valueType === 'color'
71
- ? 'identity'
72
- : 'linear');
73
- }
74
- // opacity: typeof === 'number' && between [0,1]
@@ -1,17 +0,0 @@
1
- export class Mark {
2
- id;
3
- type;
4
- automatic;
5
- channels = $state(new Set());
6
- props = $state();
7
- constructor(type, channels, automatic, props) {
8
- this.id = Symbol();
9
- this.type = type;
10
- this.automatic = automatic;
11
- this.channels = new Set(channels);
12
- this.props = props;
13
- }
14
- toString() {
15
- return `Mark[${this.type}]`;
16
- }
17
- }
@@ -1,98 +0,0 @@
1
- import { createScale, createColorScale } from '../helpers/createScale.js';
2
- import mergeDeep from '../helpers/mergeDeep.js';
3
- import { Channel } from './Channel.svelte';
4
- import { get } from 'underscore';
5
- export const DEFAULT_PLOT_OPTIONS = {
6
- title: '',
7
- subtitle: '',
8
- caption: '',
9
- marginLeft: 0,
10
- marginRight: 0,
11
- marginTop: 30,
12
- marginBottom: 0,
13
- radius: { range: [1, 10] },
14
- symbol: {},
15
- color: {},
16
- x: {
17
- domain: undefined,
18
- grid: false,
19
- ticks: undefined,
20
- tickSpacing: 80,
21
- axis: 'bottom',
22
- log: false,
23
- reverse: false
24
- },
25
- y: {
26
- domain: undefined,
27
- grid: false,
28
- ticks: undefined,
29
- tickSpacing: 60,
30
- axis: 'left',
31
- log: false,
32
- reverse: false
33
- }
34
- };
35
- export class Plot {
36
- width = $state(600);
37
- _height = $state(400);
38
- options = $state(DEFAULT_PLOT_OPTIONS);
39
- marks = $state([]);
40
- hasChannelX = $derived(!!this.marks.find((mark) => mark.channels.has('x')));
41
- hasChannelY = $derived(!!this.marks.find((mark) => mark.channels.has('y')));
42
- hasFilledDotMarks = $derived(!!this.marks.find((d) => d.type === 'dot' && d.props?.fill));
43
- manualMarks = $derived(this.marks.filter((mark) => !mark.automatic));
44
- singlePosChannelMark = $derived(this.manualMarks.length === 1 &&
45
- (!this.manualMarks[0].channels.has('x') || !this.manualMarks[0].channels.has('y')));
46
- height = $derived(this._height === 'auto' ? (this.hasChannelY ? 400 : 90) : this._height);
47
- inset = $derived(typeof this.options.inset === 'number'
48
- ? this.options.inset
49
- : this.singlePosChannelMark
50
- ? 10
51
- : 0);
52
- // derived props
53
- margins = $derived({
54
- top: this.options.marginTop,
55
- left: this.options.marginLeft,
56
- bottom: this.options.marginBottom,
57
- right: this.options.marginRight
58
- });
59
- // margins = $state<Margins>({ left: 0, right: 0, top: 0, bottom: 0 });
60
- plotWidth = $derived(this.width - this.margins.left - this.margins.right);
61
- plotHeight = $derived(this.height - this.margins.top - this.margins.bottom);
62
- x = new Channel('x', this);
63
- y = new Channel('y', this);
64
- radius = new Channel('radius', this);
65
- color = new Channel('color', this);
66
- symbol = new Channel('symbol', this);
67
- colorSymbolRedundant = $derived(this.color.uniqueMarkProps.length === 1 &&
68
- this.symbol.uniqueMarkProps.length === 1 &&
69
- this.color.uniqueMarkProps[0] === this.symbol.uniqueMarkProps[0]);
70
- xScale = $derived(createScale(this.x.scaleType === 'linear' && this.options.x.log ? 'log' : this.x.scaleType, this.options?.x?.domain || this.x.domain, this.options?.x?.reverse
71
- ? [this.margins.left + this.plotWidth - this.inset, this.margins.left + this.inset]
72
- : [this.margins.left + this.inset, this.margins.left + this.plotWidth - this.inset], this.x.scaleType === 'linear' && this.options.x.log ? { base: 10 } : {}));
73
- yScale = $derived(createScale(this.y.scaleType === 'linear' && this.options.y.log ? 'log' : this.y.scaleType, this.options.y?.domain || this.y.domain, this.options.y?.reverse
74
- ? [this.margins.top + this.inset, this.height - this.margins.bottom - this.inset]
75
- : [this.height - this.margins.bottom - this.inset, this.margins.top + this.inset], this.y.scaleType === 'linear' && this.options.y.log ? { base: '10' } : {}));
76
- radiusScale = $derived(createScale(this.radius.scaleType, [0, Math.max(this.radius.domain[0], this.radius.domain[1])], this.options.radius.range));
77
- symbolScale = $derived(createScale('ordinal', this.symbol.domain, this.options.symbol?.range || this.hasFilledDotMarks
78
- ? ['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']
79
- : ['circle', 'plus', 'times', 'triangle2', 'asterisk', 'square2', 'diamond2']));
80
- colorScale = $derived(createColorScale(this.color.scaleType, this.color.domain, this.options.color?.range || null, this.options.color?.scheme));
81
- hasAxisXMark = $derived(!!this.marks.find((mark) => mark.type === 'axis-x' && !mark.automatic));
82
- hasAxisYMark = $derived(!!this.marks.find((mark) => mark.type === 'axis-y' && !mark.automatic));
83
- constructor(width, height, options) {
84
- const opts = mergeDeep({}, DEFAULT_PLOT_OPTIONS, options);
85
- this.width = width;
86
- this._height = height;
87
- this.options = opts;
88
- }
89
- addMark(mark) {
90
- // console.log('addMark: ' + mark);
91
- this.marks = [...this.marks, mark];
92
- // add mark to respective channels
93
- // console.log(this.x.domain);
94
- }
95
- removeMark(removeMark) {
96
- this.marks = this.marks.filter((mark) => mark.id !== removeMark.id);
97
- }
98
- }
@@ -1,3 +0,0 @@
1
- import type { ChannelName, MarkProps, MarkStyleProps } from './types';
2
- export declare const CHANNEL_TYPES: Record<ChannelName, symbol>;
3
- export declare const MARK_PROP_CHANNEL: Record<MarkProps & MarkStyleProps, ChannelName>;
package/dist/contants.js DELETED
@@ -1,40 +0,0 @@
1
- export const CHANNEL_TYPES = {
2
- opacity: Symbol('opacity'),
3
- color: Symbol('color'),
4
- x: Symbol('position'),
5
- y: Symbol('position'),
6
- angle: Symbol('angle'),
7
- symbol: Symbol('symbol'),
8
- radius: Symbol('radius'),
9
- width: Symbol('width')
10
- };
11
- export const MARK_PROP_CHANNEL = {
12
- x: 'x',
13
- x1: 'x',
14
- x2: 'x',
15
- y: 'y',
16
- y1: 'y',
17
- y2: 'y',
18
- rotate: 'angle',
19
- r: 'radius',
20
- symbol: 'symbol',
21
- fill: 'color',
22
- stroke: 'color',
23
- opacity: 'opacity',
24
- fillOpacity: 'opacity',
25
- strokeOpacity: 'opacity',
26
- strokeWidth: 'width'
27
- };
28
- // export const CHANNEL_MAP: Record<ChannelName, ValueOf<typeof CHANNEL_TYPES>> = {
29
- // x: CHANNEL_TYPES.x,
30
- // y: CHANNEL_TYPES.y,
31
- // opacity: CHANNEL_TYPES.opacity,
32
- // strokeOpacity: CHANNEL_TYPES.opacity,
33
- // strokeWidth: CHANNEL_TYPES.width,
34
- // fillOpacity: CHANNEL_TYPES.opacity,
35
- // stroke: CHANNEL_TYPES.color,
36
- // fill: CHANNEL_TYPES.color,
37
- // r: CHANNEL_TYPES.radius,
38
- // rotate: CHANNEL_TYPES.angle,
39
- // symbol: CHANNEL_TYPES.symbol
40
- // };
@@ -1,8 +0,0 @@
1
- <script>let { data = [], ...rest } = $props();
2
- </script>
3
-
4
- {#if data.length !== 1}
5
- <g {...rest}><slot /></g>
6
- {:else}
7
- <slot />
8
- {/if}