svelteplot 0.8.1 → 0.9.0-pr-311.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.
Files changed (131) hide show
  1. package/README.md +4 -3
  2. package/dist/Mark.svelte +1 -1
  3. package/dist/Mark.svelte.d.ts +6 -4
  4. package/dist/constants.d.ts +3 -1
  5. package/dist/constants.js +11 -2
  6. package/dist/core/Plot.svelte +4 -4
  7. package/dist/helpers/autoScales.d.ts +1 -1
  8. package/dist/helpers/callWithProps.d.ts +1 -3
  9. package/dist/helpers/callWithProps.js +5 -3
  10. package/dist/helpers/colors.d.ts +9 -12
  11. package/dist/helpers/facets.d.ts +1 -1
  12. package/dist/helpers/getBaseStyles.d.ts +2 -4
  13. package/dist/helpers/index.d.ts +3 -3
  14. package/dist/helpers/projection.js +7 -2
  15. package/dist/helpers/reduce.d.ts +1 -1
  16. package/dist/helpers/scales.d.ts +7 -7
  17. package/dist/helpers/symbols.d.ts +2 -2
  18. package/dist/helpers/time.d.ts +3 -3
  19. package/dist/helpers/typeChecks.d.ts +8 -8
  20. package/dist/hooks/usePlot.svelte.d.ts +51 -0
  21. package/dist/hooks/usePlot.svelte.js +90 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/marks/Area.svelte +3 -5
  25. package/dist/marks/Area.svelte.d.ts +6 -4
  26. package/dist/marks/AreaX.svelte.d.ts +7 -5
  27. package/dist/marks/Arrow.svelte +3 -5
  28. package/dist/marks/Arrow.svelte.d.ts +6 -4
  29. package/dist/marks/AxisX.svelte +2 -3
  30. package/dist/marks/AxisX.svelte.d.ts +7 -5
  31. package/dist/marks/AxisY.svelte +3 -4
  32. package/dist/marks/AxisY.svelte.d.ts +7 -5
  33. package/dist/marks/BarX.svelte +2 -4
  34. package/dist/marks/BarX.svelte.d.ts +6 -4
  35. package/dist/marks/BarY.svelte +2 -4
  36. package/dist/marks/BarY.svelte.d.ts +6 -4
  37. package/dist/marks/BollingerX.svelte.d.ts +2 -76
  38. package/dist/marks/BollingerY.svelte.d.ts +2 -76
  39. package/dist/marks/BoxX.svelte +4 -138
  40. package/dist/marks/BoxY.svelte +20 -137
  41. package/dist/marks/BoxY.svelte.d.ts +6 -64
  42. package/dist/marks/Brush.svelte +3 -3
  43. package/dist/marks/Brush.svelte.d.ts +1 -63
  44. package/dist/marks/Cell.svelte +2 -4
  45. package/dist/marks/Cell.svelte.d.ts +6 -4
  46. package/dist/marks/ColorLegend.svelte +2 -4
  47. package/dist/marks/CustomMark.svelte.d.ts +2 -84
  48. package/dist/marks/CustomMarkHTML.svelte +5 -10
  49. package/dist/marks/DifferenceY.svelte +3 -5
  50. package/dist/marks/DifferenceY.svelte.d.ts +1 -63
  51. package/dist/marks/Dot.svelte +4 -5
  52. package/dist/marks/Dot.svelte.d.ts +6 -4
  53. package/dist/marks/DotX.svelte.d.ts +7 -5
  54. package/dist/marks/DotY.svelte.d.ts +7 -5
  55. package/dist/marks/Frame.svelte +3 -9
  56. package/dist/marks/Frame.svelte.d.ts +7 -5
  57. package/dist/marks/Geo.svelte +5 -5
  58. package/dist/marks/Geo.svelte.d.ts +7 -4
  59. package/dist/marks/GridX.svelte +3 -10
  60. package/dist/marks/GridX.svelte.d.ts +6 -4
  61. package/dist/marks/GridY.svelte +3 -4
  62. package/dist/marks/GridY.svelte.d.ts +6 -4
  63. package/dist/marks/HTMLTooltip.svelte +5 -5
  64. package/dist/marks/Image.svelte.d.ts +2 -75
  65. package/dist/marks/Line.svelte +7 -6
  66. package/dist/marks/Line.svelte.d.ts +6 -4
  67. package/dist/marks/LineX.svelte.d.ts +8 -6
  68. package/dist/marks/LineY.svelte.d.ts +8 -6
  69. package/dist/marks/Link.svelte +2 -4
  70. package/dist/marks/Link.svelte.d.ts +6 -4
  71. package/dist/marks/Pointer.svelte +4 -4
  72. package/dist/marks/Rect.svelte +2 -4
  73. package/dist/marks/Rect.svelte.d.ts +6 -4
  74. package/dist/marks/RectX.svelte +4 -4
  75. package/dist/marks/RectY.svelte +4 -4
  76. package/dist/marks/RuleX.svelte +2 -4
  77. package/dist/marks/RuleX.svelte.d.ts +6 -4
  78. package/dist/marks/RuleY.svelte +2 -4
  79. package/dist/marks/RuleY.svelte.d.ts +6 -4
  80. package/dist/marks/Spike.svelte.d.ts +7 -5
  81. package/dist/marks/SymbolLegend.svelte +2 -4
  82. package/dist/marks/SymbolLegend.svelte.d.ts +17 -2
  83. package/dist/marks/Text.svelte.d.ts +6 -4
  84. package/dist/marks/TickX.svelte +2 -3
  85. package/dist/marks/TickX.svelte.d.ts +6 -4
  86. package/dist/marks/TickY.svelte +2 -3
  87. package/dist/marks/TickY.svelte.d.ts +6 -4
  88. package/dist/marks/Trail.svelte +161 -0
  89. package/dist/marks/Trail.svelte.d.ts +44 -0
  90. package/dist/marks/Vector.svelte +3 -4
  91. package/dist/marks/Vector.svelte.d.ts +6 -4
  92. package/dist/marks/WaffleX.svelte +3 -4
  93. package/dist/marks/WaffleX.svelte.d.ts +2 -85
  94. package/dist/marks/WaffleY.svelte +2 -4
  95. package/dist/marks/WaffleY.svelte.d.ts +2 -83
  96. package/dist/marks/helpers/AreaCanvas.svelte +2 -4
  97. package/dist/marks/helpers/Box.svelte +271 -0
  98. package/dist/marks/helpers/Box.svelte.d.ts +55 -0
  99. package/dist/marks/helpers/CanvasLayer.svelte +2 -4
  100. package/dist/marks/helpers/DotCanvas.svelte +3 -5
  101. package/dist/marks/helpers/GeoCanvas.svelte +2 -4
  102. package/dist/marks/helpers/LineCanvas.svelte +2 -4
  103. package/dist/marks/helpers/LinearGradientX.svelte +3 -4
  104. package/dist/marks/helpers/LinearGradientY.svelte +3 -4
  105. package/dist/marks/helpers/MarkerPath.svelte +4 -5
  106. package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -102
  107. package/dist/marks/helpers/MultilineText.svelte +4 -4
  108. package/dist/marks/helpers/RectPath.svelte +5 -6
  109. package/dist/marks/helpers/Regression.svelte +4 -8
  110. package/dist/marks/helpers/TrailCanvas.svelte +138 -0
  111. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +40 -0
  112. package/dist/marks/helpers/events.d.ts +2 -2
  113. package/dist/marks/helpers/events.js +4 -4
  114. package/dist/marks/helpers/trail.d.ts +23 -0
  115. package/dist/marks/helpers/trail.js +372 -0
  116. package/dist/marks/index.d.ts +1 -0
  117. package/dist/marks/index.js +1 -0
  118. package/dist/transforms/bollinger.d.ts +1 -69
  119. package/dist/transforms/centroid.d.ts +1 -4
  120. package/dist/transforms/group.d.ts +4 -12
  121. package/dist/transforms/interval.d.ts +2 -128
  122. package/dist/transforms/normalize.d.ts +23 -0
  123. package/dist/transforms/recordize.d.ts +4 -7
  124. package/dist/transforms/select.d.ts +7 -448
  125. package/dist/transforms/sort.d.ts +5 -253
  126. package/dist/transforms/stack.d.ts +3 -23
  127. package/dist/transforms/window.d.ts +2 -134
  128. package/dist/types/mark.d.ts +2 -1
  129. package/dist/types/plot.d.ts +6 -1
  130. package/dist/ui/Spiral.svelte +4 -0
  131. package/package.json +25 -23
@@ -1,3 +1,4 @@
1
+ import { recordizeY } from '../transforms/recordize.js';
1
2
  import type { DataRecord, ConstantAccessor, ChannelAccessor } from '../types/index.js';
2
3
  declare function $$render<Datum = DataRecord>(): {
3
4
  props: Omit<Partial<{
@@ -7,14 +8,14 @@ declare function $$render<Datum = DataRecord>(): {
7
8
  fy: ChannelAccessor<Datum>;
8
9
  dx: ConstantAccessor<number, Datum>;
9
10
  dy: ConstantAccessor<number, Datum>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: recordizeY;
12
+ dodgeY: recordizeY;
12
13
  fill: ChannelAccessor<Datum>;
13
14
  fillOpacity: ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
19
  stroke: ChannelAccessor<Datum>;
19
20
  strokeWidth: ConstantAccessor<number, Datum>;
20
21
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -26,6 +27,7 @@ declare function $$render<Datum = DataRecord>(): {
26
27
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
28
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: ConstantAccessor<string, Datum>;
30
32
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
33
  paintOrder: ConstantAccessor<string, Datum>;
@@ -1,4 +1,5 @@
1
1
  import type { ChannelAccessor, DataRecord } from '../types/index.js';
2
+ import { getPlotDefaults } from '../hooks/plotDefaults.js';
2
3
  declare function $$render<Datum extends DataRecord>(): {
3
4
  props: Omit<Partial<{
4
5
  filter: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/data").RawValue>>;
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRecord>(): {
7
8
  fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
8
9
  dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
9
10
  dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: getPlotDefaults;
12
+ dodgeY: getPlotDefaults;
12
13
  fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
13
14
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
14
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
18
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
18
19
  stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
19
20
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
20
21
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends DataRecord>(): {
26
27
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
27
28
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
30
32
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
31
33
  paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
@@ -73,7 +75,7 @@ declare function $$render<Datum extends DataRecord>(): {
73
75
  shape?: "arrow" | "spike" | "arrow-filled" | import("./Vector.svelte").ShapeRenderer;
74
76
  children?: import("svelte").Snippet;
75
77
  canvas?: boolean;
76
- }, "data" | "r" | "length" | "x" | "y" | "rotate"> & {
78
+ }, "r" | "length" | "x" | "y" | "data" | "rotate"> & {
77
79
  data: Datum[];
78
80
  x: ChannelAccessor<Datum>;
79
81
  y: ChannelAccessor<Datum>;
@@ -1,11 +1,9 @@
1
1
  <script lang="ts">
2
- import { getContext } from 'svelte';
3
2
  import { symbol as d3Symbol } from 'd3-shape';
4
3
  import { maybeSymbol } from '../helpers/symbols.js';
5
- import type { PlotContext } from '../types/index.js';
4
+ import { usePlot } from '../hooks/usePlot.svelte.js';
6
5
 
7
- const { getPlotState } = getContext<PlotContext>('svelteplot');
8
- let plot = $derived(getPlotState());
6
+ const plot = usePlot();
9
7
 
10
8
  // TODO: allow styling of legend
11
9
  </script>
@@ -1,8 +1,23 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
1
14
  /**
2
15
  * The SymbolLegend is an HTML mark that can be placed in the header, footer and overlay
3
16
  * snippets. You can activate an implicit SymbolLegend above the chart using the global
4
17
  * symbol.legend scale option.
5
18
  */
6
- declare const SymbolLegend: import("svelte").Component<Record<string, never>, {}, "">;
7
- type SymbolLegend = ReturnType<typeof SymbolLegend>;
19
+ declare const SymbolLegend: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
20
+ [evt: string]: CustomEvent<any>;
21
+ }, {}, {}, string>;
22
+ type SymbolLegend = InstanceType<typeof SymbolLegend>;
8
23
  export default SymbolLegend;
@@ -1,6 +1,7 @@
1
1
  import type * as CSS from 'csstype';
2
2
  import { type Snippet } from 'svelte';
3
3
  import type { DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
4
+ import { sort } from '../index.js';
4
5
  declare function $$render<Datum extends DataRecord>(): {
5
6
  props: Partial<{
6
7
  filter: ConstantAccessor<boolean, Datum>;
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRecord>(): {
9
10
  fy: ChannelAccessor<Datum>;
10
11
  dx: ConstantAccessor<number, Datum>;
11
12
  dy: ConstantAccessor<number, Datum>;
12
- dodgeX: import("../transforms/dodge").DodgeXOptions;
13
- dodgeY: import("../transforms/dodge").DodgeYOptions;
13
+ dodgeX: sort;
14
+ dodgeY: sort;
14
15
  fill: ChannelAccessor<Datum>;
15
16
  fillOpacity: ConstantAccessor<number, Datum>;
16
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
17
+ sort: {
17
18
  channel: string;
18
19
  order?: "ascending" | "descending";
19
- } | ConstantAccessor<import("../types/data").RawValue, Datum>;
20
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
20
21
  stroke: ChannelAccessor<Datum>;
21
22
  strokeWidth: ConstantAccessor<number, Datum>;
22
23
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -28,6 +29,7 @@ declare function $$render<Datum extends DataRecord>(): {
28
29
  strokeDashoffset: ConstantAccessor<number, Datum>;
29
30
  mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
30
31
  clipPath: string;
32
+ mask: string;
31
33
  imageFilter: ConstantAccessor<string, Datum>;
32
34
  shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
33
35
  paintOrder: ConstantAccessor<string, Datum>;
@@ -25,7 +25,6 @@
25
25
  import { getContext } from 'svelte';
26
26
  import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
27
27
  import type {
28
- PlotContext,
29
28
  BaseMarkProps,
30
29
  ChannelAccessor,
31
30
  DataRow,
@@ -37,9 +36,9 @@
37
36
  import { isValid } from '../helpers/index.js';
38
37
  import { testFilter, parseInset } from '../helpers/index.js';
39
38
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
39
+ import { usePlot } from '../hooks/usePlot.svelte.js';
40
40
 
41
- const { getPlotState } = getContext<PlotContext>('svelteplot');
42
- let plot = $derived(getPlotState());
41
+ const plot = usePlot();
43
42
 
44
43
  let markProps: TickXMarkProps = $props();
45
44
  const DEFAULTS = {
@@ -1,4 +1,5 @@
1
1
  import type { ChannelAccessor, DataRow, ConstantAccessor } from '../types/index.js';
2
+ import { recordizeX } from '../index.js';
2
3
  declare function $$render<Datum extends DataRow>(): {
3
4
  props: Omit<Partial<{
4
5
  filter: ConstantAccessor<boolean, Datum>;
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
7
8
  fy: ChannelAccessor<Datum>;
8
9
  dx: ConstantAccessor<number, Datum>;
9
10
  dy: ConstantAccessor<number, Datum>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: recordizeX;
12
+ dodgeY: recordizeX;
12
13
  fill: ChannelAccessor<Datum>;
13
14
  fillOpacity: ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
19
  stroke: ChannelAccessor<Datum>;
19
20
  strokeWidth: ConstantAccessor<number, Datum>;
20
21
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
26
27
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
28
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: ConstantAccessor<string, Datum>;
30
32
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
33
  paintOrder: ConstantAccessor<string, Datum>;
@@ -24,7 +24,6 @@
24
24
  import { getContext } from 'svelte';
25
25
  import { resolveChannel, resolveProp, resolveScaledStyles } from '../helpers/resolve.js';
26
26
  import type {
27
- PlotContext,
28
27
  BaseMarkProps,
29
28
  ChannelAccessor,
30
29
  DataRow,
@@ -36,9 +35,9 @@
36
35
  import { isValid } from '../helpers/index.js';
37
36
  import { testFilter, parseInset } from '../helpers/index.js';
38
37
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
38
+ import { usePlot } from '../hooks/usePlot.svelte.js';
39
39
 
40
- const { getPlotState } = getContext<PlotContext>('svelteplot');
41
- let plot = $derived(getPlotState());
40
+ const plot = usePlot();
42
41
 
43
42
  let markProps: TickYMarkProps = $props();
44
43
  const DEFAULTS = {
@@ -1,4 +1,5 @@
1
1
  import type { ChannelAccessor, DataRow, ConstantAccessor } from '../types/index.js';
2
+ import { recordizeY } from '../index.js';
2
3
  declare function $$render<Datum extends DataRow>(): {
3
4
  props: Omit<Partial<{
4
5
  filter: ConstantAccessor<boolean, Datum>;
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
7
8
  fy: ChannelAccessor<Datum>;
8
9
  dx: ConstantAccessor<number, Datum>;
9
10
  dy: ConstantAccessor<number, Datum>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: recordizeY;
12
+ dodgeY: recordizeY;
12
13
  fill: ChannelAccessor<Datum>;
13
14
  fillOpacity: ConstantAccessor<number, Datum>;
14
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | ConstantAccessor<import("../types/data").RawValue, Datum>;
18
19
  stroke: ChannelAccessor<Datum>;
19
20
  strokeWidth: ConstantAccessor<number, Datum>;
20
21
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
26
27
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
28
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: ConstantAccessor<string, Datum>;
30
32
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
33
  paintOrder: ConstantAccessor<string, Datum>;
@@ -0,0 +1,161 @@
1
+ <script lang="ts" generics="Datum extends DataRecord">
2
+ interface TrailMarkProps extends Omit<
3
+ BaseMarkProps<Datum>,
4
+ 'stroke' | 'strokeWidth' | 'strokeDasharray'
5
+ > {
6
+ data?: Datum[];
7
+ x?: ChannelAccessor<Datum>;
8
+ y?: ChannelAccessor<Datum>;
9
+ z?: ChannelAccessor<Datum>;
10
+ r?: ChannelAccessor<Datum>;
11
+ curve?: CurveName | CurveFactory;
12
+ tension?: number;
13
+ sort?: ConstantAccessor<RawValue, Datum> | { channel: 'stroke' | 'fill' };
14
+ defined?: ConstantAccessor<boolean, Datum>;
15
+ canvas?: boolean;
16
+ cap?: 'butt' | 'round';
17
+ /**
18
+ * Samples per segment for curve interpolation
19
+ */
20
+ resolution?: number | 'auto';
21
+ }
22
+ import type {
23
+ DataRecord,
24
+ ChannelAccessor,
25
+ BaseMarkProps,
26
+ ConstantAccessor,
27
+ RawValue,
28
+ ScaledDataRecord,
29
+ CurveName
30
+ } from '../types';
31
+ import Mark from '../Mark.svelte';
32
+ import { path as d3Path } from 'd3-path';
33
+ import { resolveProp, resolveStyles } from '../helpers/resolve.js';
34
+ import { getPlotDefaults } from '../hooks/plotDefaults';
35
+ import { sort } from '../transforms';
36
+ import trailPath, { type TrailSample } from './helpers/trail.js';
37
+ import TrailCanvas from './helpers/TrailCanvas.svelte';
38
+ import { addEventHandlers } from './helpers/events';
39
+ import type { CurveFactory } from 'd3-shape';
40
+ import { usePlot } from '../hooks/usePlot.svelte.js';
41
+
42
+ let markProps: TrailMarkProps = $props();
43
+
44
+ const DEFAULTS: TrailMarkProps = {
45
+ curve: 'linear',
46
+ r: 3,
47
+ canvas: false,
48
+ resolution: 'auto',
49
+ cap: 'round',
50
+ tension: 0,
51
+ ...getPlotDefaults().trail
52
+ };
53
+
54
+ const {
55
+ data = [{} as Datum],
56
+ curve,
57
+ resolution,
58
+ tension,
59
+ canvas,
60
+ cap,
61
+ class: className,
62
+ ...options
63
+ }: TrailMarkProps = $derived({
64
+ ...DEFAULTS,
65
+ ...markProps
66
+ });
67
+
68
+ const args = $derived(sort({ data, ...options })) as TrailMarkProps;
69
+
70
+ const plot = usePlot();
71
+
72
+ /**
73
+ * Groups the data by the specified key
74
+ */
75
+ function groupIndex(data: ScaledDataRecord[], groupByKey: ChannelAccessor<Datum> | null) {
76
+ if (!groupByKey) return [data];
77
+ let group: ScaledDataRecord[] = [];
78
+ const groups = [group];
79
+ let lastGroupValue;
80
+ for (const d of data) {
81
+ const groupValue = resolveProp(groupByKey, d.datum);
82
+ if (groupValue === lastGroupValue || group.length === 0) {
83
+ group.push(d);
84
+ lastGroupValue = groupValue;
85
+ } else {
86
+ // new group
87
+ group = [d];
88
+ groups.push(group);
89
+ lastGroupValue = groupValue;
90
+ }
91
+ }
92
+ return groups.filter((d) => d.length > 0);
93
+ }
94
+
95
+ const groupByKey = $derived(args.z || args.fill) as ChannelAccessor<Datum> | null;
96
+ </script>
97
+
98
+ <Mark
99
+ type="trail"
100
+ channels={['x', 'y', 'opacity', 'fill', 'fillOpacity', 'r']}
101
+ required={['x', 'y']}
102
+ {...args}>
103
+ {#snippet children({ mark, usedScales, scaledData })}
104
+ {#if scaledData.length > 0}
105
+ {@const groupedTrailData = groupIndex(scaledData, groupByKey)}
106
+ {#if canvas}
107
+ <!-- todo -->
108
+ <TrailCanvas
109
+ {curve}
110
+ {cap}
111
+ {tension}
112
+ {resolution}
113
+ {usedScales}
114
+ data={groupedTrailData}
115
+ options={args} />
116
+ {:else}
117
+ <g class={['trail', className]}>
118
+ {#each groupedTrailData as trailData, i (i)}
119
+ {@const samples = trailData.map((d) => ({
120
+ x: Number(d.x),
121
+ y: Number(d.y),
122
+ r: Number(d.r ?? 0)
123
+ })) satisfies TrailSample[]}
124
+ {@const defined = trailData.map(
125
+ (d) =>
126
+ d.valid &&
127
+ d.r >= 0 &&
128
+ (resolveProp(options.defined, d.datum, true) ?? true)
129
+ )}
130
+ {@const pathString = trailPath(samples, defined, d3Path(), {
131
+ curve,
132
+ cap,
133
+ tension,
134
+ ...(typeof resolution === 'number'
135
+ ? { samplesPerSegment: resolution }
136
+ : {})
137
+ })}
138
+ {@const [style, styleClass] = resolveStyles(
139
+ plot,
140
+ trailData[0],
141
+ {
142
+ ...args
143
+ },
144
+ 'fill',
145
+ usedScales
146
+ )}
147
+ <path
148
+ d={pathString}
149
+ {style}
150
+ class={styleClass}
151
+ {@attach addEventHandlers({
152
+ plot,
153
+ options: mark.options,
154
+ datum: trailData[0].datum
155
+ })} />
156
+ {/each}
157
+ </g>
158
+ {/if}
159
+ {/if}
160
+ {/snippet}
161
+ </Mark>
@@ -0,0 +1,44 @@
1
+ import type { DataRecord, ChannelAccessor, ConstantAccessor, RawValue, CurveName } from '../types';
2
+ import type { CurveFactory } from 'd3-shape';
3
+ declare function $$render<Datum extends DataRecord>(): {
4
+ props: Omit<BaseMarkProps<Datum>, "stroke" | "strokeDasharray" | "strokeWidth"> & {
5
+ data?: Datum[];
6
+ x?: ChannelAccessor<Datum>;
7
+ y?: ChannelAccessor<Datum>;
8
+ z?: ChannelAccessor<Datum>;
9
+ r?: ChannelAccessor<Datum>;
10
+ curve?: CurveName | CurveFactory;
11
+ tension?: number;
12
+ sort?: ConstantAccessor<RawValue, Datum> | {
13
+ channel: "stroke" | "fill";
14
+ };
15
+ defined?: ConstantAccessor<boolean, Datum>;
16
+ canvas?: boolean;
17
+ cap?: "butt" | "round";
18
+ /**
19
+ * Samples per segment for curve interpolation
20
+ */
21
+ resolution?: number | "auto";
22
+ };
23
+ exports: {};
24
+ bindings: "";
25
+ slots: {};
26
+ events: {};
27
+ };
28
+ declare class __sveltets_Render<Datum extends DataRecord> {
29
+ props(): ReturnType<typeof $$render<Datum>>['props'];
30
+ events(): ReturnType<typeof $$render<Datum>>['events'];
31
+ slots(): ReturnType<typeof $$render<Datum>>['slots'];
32
+ bindings(): "";
33
+ exports(): {};
34
+ }
35
+ interface $$IsomorphicComponent {
36
+ new <Datum extends DataRecord>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<Datum>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<Datum>['props']>, ReturnType<__sveltets_Render<Datum>['events']>, ReturnType<__sveltets_Render<Datum>['slots']>> & {
37
+ $$bindings?: ReturnType<__sveltets_Render<Datum>['bindings']>;
38
+ } & ReturnType<__sveltets_Render<Datum>['exports']>;
39
+ <Datum extends DataRecord>(internal: unknown, props: ReturnType<__sveltets_Render<Datum>['props']> & {}): ReturnType<__sveltets_Render<Datum>['exports']>;
40
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
41
+ }
42
+ declare const Trail: $$IsomorphicComponent;
43
+ type Trail<Datum extends DataRecord> = InstanceType<typeof Trail<Datum>>;
44
+ export default Trail;
@@ -29,7 +29,6 @@
29
29
  canvas?: boolean;
30
30
  }
31
31
  import type {
32
- PlotContext,
33
32
  DataRecord,
34
33
  BaseMarkProps,
35
34
  ChannelAccessor,
@@ -47,6 +46,7 @@
47
46
  import { addEventHandlers } from './helpers/events.js';
48
47
  import { indexData } from '../transforms/recordize.js';
49
48
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
49
+ import { usePlot } from '../hooks/usePlot.svelte.js';
50
50
 
51
51
  const defaultRadius = 3.5;
52
52
 
@@ -72,8 +72,7 @@
72
72
  ...markProps
73
73
  });
74
74
 
75
- const { getPlotState } = getContext<PlotContext>('svelteplot');
76
- const plot = $derived(getPlotState());
75
+ const plot = usePlot();
77
76
 
78
77
  const { getTestFacet } = getContext<FacetContext>('svelteplot/facet');
79
78
  const testFacet = $derived(getTestFacet());
@@ -203,7 +202,7 @@
203
202
  : `translate(0, ${d.length / 2})`}"
204
203
  {style}
205
204
  {@attach addEventHandlers({
206
- getPlotState,
205
+ plot,
207
206
  options: args,
208
207
  datum: d?.datum
209
208
  })}
@@ -4,6 +4,7 @@ export type ShapeRenderer = {
4
4
  };
5
5
  import type { DataRecord, ChannelAccessor } from '../types/index.js';
6
6
  import { type Snippet } from 'svelte';
7
+ import { sort } from '../index.js';
7
8
  declare function $$render<Datum extends DataRecord>(): {
8
9
  props: Partial<{
9
10
  filter: import("../types/index.js").ConstantAccessor<boolean, Datum>;
@@ -12,14 +13,14 @@ declare function $$render<Datum extends DataRecord>(): {
12
13
  fy: ChannelAccessor<Datum>;
13
14
  dx: import("../types/index.js").ConstantAccessor<number, Datum>;
14
15
  dy: import("../types/index.js").ConstantAccessor<number, Datum>;
15
- dodgeX: import("../transforms/dodge.js").DodgeXOptions;
16
- dodgeY: import("../transforms/dodge.js").DodgeYOptions;
16
+ dodgeX: sort;
17
+ dodgeY: sort;
17
18
  fill: ChannelAccessor<Datum>;
18
19
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
19
- sort: ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | {
20
+ sort: {
20
21
  channel: string;
21
22
  order?: "ascending" | "descending";
22
- } | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
23
+ } | ((a: import("../types/data.js").RawValue, b: import("../types/data.js").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data.js").RawValue, Datum>;
23
24
  stroke: ChannelAccessor<Datum>;
24
25
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
25
26
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
@@ -31,6 +32,7 @@ declare function $$render<Datum extends DataRecord>(): {
31
32
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
32
33
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
33
34
  clipPath: string;
35
+ mask: string;
34
36
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
35
37
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
36
38
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -15,9 +15,9 @@
15
15
  import { intervalX, recordizeX, sort, stackX } from '../transforms';
16
16
  import type { StackOptions } from '../transforms/stack';
17
17
  import Mark from '../Mark.svelte';
18
- import { getContext } from 'svelte';
19
18
  import { resolveProp, resolveStyles } from '../helpers/resolve';
20
19
  import { roundedRect } from '../helpers/roundedRect';
20
+ import { usePlot } from '../hooks/usePlot.svelte.js';
21
21
 
22
22
  interface WaffleXMarkProps
23
23
  extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, WaffleOptions<Datum> {
@@ -58,8 +58,7 @@
58
58
  ...options
59
59
  }: WaffleXMarkProps = $derived({ ...DEFAULTS, ...markProps });
60
60
 
61
- const { getPlotState } = getContext<PlotContext>('svelteplot');
62
- const plot = $derived(getPlotState());
61
+ const plot = usePlot();
63
62
 
64
63
  const args = $derived(
65
64
  stackX(
@@ -96,7 +95,7 @@
96
95
  <g class={['waffle-x', className]}>
97
96
  <pattern {...pattern}>
98
97
  {#if symbol}
99
- {@render symbol(rect)}
98
+ {@render symbol({ ...rect, style, styleClass, datum: d.datum })}
100
99
  {:else if hasBorderRadius}
101
100
  <path
102
101
  d={roundedRect(rect.x, rect.y, rect.width, rect.height, borderRadius)}