svelteplot 0.6.0-pr-266.0 → 0.7.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 (82) hide show
  1. package/dist/Mark.svelte +7 -0
  2. package/dist/Mark.svelte.d.ts +4 -5
  3. package/dist/Plot.svelte +10 -2
  4. package/dist/constants.d.ts +1 -1
  5. package/dist/core/FacetAxes.svelte +2 -2
  6. package/dist/core/Plot.svelte +7 -11
  7. package/dist/helpers/colors.d.ts +12 -9
  8. package/dist/helpers/facets.d.ts +1 -1
  9. package/dist/helpers/getBaseStyles.d.ts +6 -2
  10. package/dist/helpers/getBaseStyles.js +8 -0
  11. package/dist/helpers/index.d.ts +3 -3
  12. package/dist/helpers/reduce.d.ts +1 -1
  13. package/dist/helpers/removeIdenticalLines.js +3 -2
  14. package/dist/helpers/scales.d.ts +7 -7
  15. package/dist/helpers/scales.js +2 -2
  16. package/dist/helpers/symbols.d.ts +2 -2
  17. package/dist/helpers/time.d.ts +3 -3
  18. package/dist/helpers/typeChecks.d.ts +8 -8
  19. package/dist/helpers/wordwrap.d.ts +14 -0
  20. package/dist/helpers/wordwrap.js +129 -0
  21. package/dist/marks/Area.svelte.d.ts +4 -5
  22. package/dist/marks/AreaX.svelte.d.ts +5 -6
  23. package/dist/marks/Arrow.svelte.d.ts +4 -5
  24. package/dist/marks/AxisX.svelte +2 -1
  25. package/dist/marks/AxisX.svelte.d.ts +6 -6
  26. package/dist/marks/AxisY.svelte.d.ts +5 -6
  27. package/dist/marks/BarX.svelte.d.ts +4 -5
  28. package/dist/marks/BarY.svelte.d.ts +4 -5
  29. package/dist/marks/BollingerX.svelte.d.ts +76 -2
  30. package/dist/marks/BollingerY.svelte.d.ts +76 -2
  31. package/dist/marks/BoxY.svelte.d.ts +68 -6
  32. package/dist/marks/Cell.svelte.d.ts +4 -5
  33. package/dist/marks/CustomMark.svelte.d.ts +84 -2
  34. package/dist/marks/CustomMarkHTML.svelte.d.ts +1 -1
  35. package/dist/marks/DifferenceY.svelte.d.ts +69 -7
  36. package/dist/marks/Dot.svelte.d.ts +4 -5
  37. package/dist/marks/DotX.svelte.d.ts +5 -6
  38. package/dist/marks/DotY.svelte.d.ts +5 -6
  39. package/dist/marks/Geo.svelte.d.ts +4 -5
  40. package/dist/marks/GridX.svelte.d.ts +4 -5
  41. package/dist/marks/GridY.svelte.d.ts +4 -5
  42. package/dist/marks/Image.svelte.d.ts +75 -2
  43. package/dist/marks/Line.svelte.d.ts +5 -6
  44. package/dist/marks/LineX.svelte.d.ts +6 -7
  45. package/dist/marks/LineY.svelte.d.ts +6 -7
  46. package/dist/marks/Link.svelte.d.ts +4 -5
  47. package/dist/marks/Rect.svelte.d.ts +4 -5
  48. package/dist/marks/RuleX.svelte.d.ts +4 -5
  49. package/dist/marks/RuleY.svelte.d.ts +4 -5
  50. package/dist/marks/Spike.svelte.d.ts +5 -6
  51. package/dist/marks/Text.svelte.d.ts +5 -6
  52. package/dist/marks/TickX.svelte.d.ts +4 -5
  53. package/dist/marks/TickY.svelte.d.ts +4 -5
  54. package/dist/marks/Vector.svelte.d.ts +4 -5
  55. package/dist/marks/WaffleX.svelte +115 -0
  56. package/dist/marks/WaffleX.svelte.d.ts +102 -0
  57. package/dist/marks/WaffleY.svelte +119 -0
  58. package/dist/marks/WaffleY.svelte.d.ts +100 -0
  59. package/dist/marks/helpers/Anchor.svelte.d.ts +5 -5
  60. package/dist/marks/helpers/BaseAxisX.svelte +31 -3
  61. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +2 -0
  62. package/dist/marks/helpers/MarkerPath.svelte.d.ts +164 -2
  63. package/dist/marks/helpers/RectPath.svelte.d.ts +65 -3
  64. package/dist/marks/helpers/waffle.d.ts +58 -0
  65. package/dist/marks/helpers/waffle.js +194 -0
  66. package/dist/marks/index.d.ts +3 -1
  67. package/dist/marks/index.js +3 -1
  68. package/dist/transforms/bollinger.d.ts +69 -1
  69. package/dist/transforms/centroid.d.ts +4 -1
  70. package/dist/transforms/group.d.ts +12 -4
  71. package/dist/transforms/group.js +11 -5
  72. package/dist/transforms/interval.d.ts +128 -2
  73. package/dist/transforms/recordize.d.ts +7 -4
  74. package/dist/transforms/select.d.ts +448 -7
  75. package/dist/transforms/sort.d.ts +253 -5
  76. package/dist/transforms/stack.d.ts +23 -3
  77. package/dist/transforms/window.d.ts +134 -2
  78. package/dist/types/data.d.ts +1 -0
  79. package/dist/types/mark.d.ts +1 -1
  80. package/dist/types/plot.d.ts +19 -5
  81. package/dist/types/scale.d.ts +8 -0
  82. package/package.json +128 -129
@@ -1,6 +1,168 @@
1
- import type { DataRecord } from '../../types/index.js';
1
+ import { type MarkerShape } from './Marker.svelte';
2
+ import type { ConstantAccessor, DataRecord, Mark, PlotScales } from '../../types/index.js';
2
3
  declare class __sveltets_Render<Datum extends DataRecord> {
3
- props(): any;
4
+ props(): Partial<{
5
+ filter: ConstantAccessor<boolean, Datum>;
6
+ facet: "auto" | "include" | "exclude";
7
+ fx: import("../../types/index.js").ChannelAccessor<Datum>;
8
+ fy: import("../../types/index.js").ChannelAccessor<Datum>;
9
+ dx: ConstantAccessor<number, Datum>;
10
+ dy: ConstantAccessor<number, Datum>;
11
+ dodgeX: import("../../transforms/dodge").DodgeXOptions;
12
+ dodgeY: import("../../transforms/dodge").DodgeYOptions;
13
+ fill: import("../../types/index.js").ChannelAccessor<Datum>;
14
+ fillOpacity: ConstantAccessor<number, Datum>;
15
+ sort: ((a: import("../../types/index.js").RawValue, b: import("../../types/index.js").RawValue) => number) | {
16
+ channel: string;
17
+ order?: "ascending" | "descending";
18
+ } | ConstantAccessor<import("../../types/index.js").RawValue, Datum>;
19
+ stroke: import("../../types/index.js").ChannelAccessor<Datum>;
20
+ strokeWidth: ConstantAccessor<number, Datum>;
21
+ strokeOpacity: ConstantAccessor<number, Datum>;
22
+ strokeLinejoin: ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
23
+ strokeLinecap: ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
24
+ strokeMiterlimit: ConstantAccessor<number, Datum>;
25
+ opacity: import("../../types/index.js").ChannelAccessor<Datum>;
26
+ strokeDasharray: ConstantAccessor<string, Datum>;
27
+ strokeDashoffset: ConstantAccessor<number, Datum>;
28
+ mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
+ clipPath: string;
30
+ imageFilter: ConstantAccessor<string, Datum>;
31
+ shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
32
+ paintOrder: ConstantAccessor<string, Datum>;
33
+ onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
34
+ ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
35
+ onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
36
+ onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
37
+ onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
38
+ onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
39
+ onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
40
+ onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
41
+ onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
42
+ onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
43
+ onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
44
+ onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
45
+ onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
46
+ onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
47
+ onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
48
+ onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
49
+ onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
50
+ ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
51
+ ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
52
+ ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
53
+ ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
54
+ ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
55
+ ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
56
+ ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
57
+ ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
58
+ ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
59
+ ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
60
+ ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
61
+ oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
62
+ onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
63
+ class: string;
64
+ style: string;
65
+ cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
66
+ }> & {
67
+ /**
68
+ * the datum associated with this path, usually the first
69
+ * element of the data array group
70
+ */
71
+ datum: Datum;
72
+ /**
73
+ * the marker shape to use at the start of the path, defaults to
74
+ * circle
75
+ */
76
+ markerStart?: boolean | MarkerShape;
77
+ /**
78
+ * the marker shape to use at the middle of the path, defaults to circle
79
+ */
80
+ markerMid?: boolean | MarkerShape;
81
+ /**
82
+ * the marker shape to use at the end of the path, defaults to circle
83
+ */
84
+ markerEnd?: boolean | MarkerShape;
85
+ /**
86
+ * shorthand for setting all markers
87
+ */
88
+ marker?: boolean | MarkerShape;
89
+ /**
90
+ * path string
91
+ */
92
+ d: string;
93
+ style: string;
94
+ startOffset: string;
95
+ textStyle: string;
96
+ textStyleClass?: string | null;
97
+ text: string;
98
+ transform: string;
99
+ color: string;
100
+ strokeWidth: ConstantAccessor<number>;
101
+ mark: Mark<Partial<{
102
+ filter: ConstantAccessor<boolean, Datum>;
103
+ facet: "auto" | "include" | "exclude";
104
+ fx: import("../../types/index.js").ChannelAccessor<Datum>;
105
+ fy: import("../../types/index.js").ChannelAccessor<Datum>;
106
+ dx: ConstantAccessor<number, Datum>;
107
+ dy: ConstantAccessor<number, Datum>;
108
+ dodgeX: import("../../transforms/dodge").DodgeXOptions;
109
+ dodgeY: import("../../transforms/dodge").DodgeYOptions;
110
+ fill: import("../../types/index.js").ChannelAccessor<Datum>;
111
+ fillOpacity: ConstantAccessor<number, Datum>;
112
+ sort: ((a: import("../../types/index.js").RawValue, b: import("../../types/index.js").RawValue) => number) | {
113
+ channel: string;
114
+ order?: "ascending" | "descending";
115
+ } | ConstantAccessor<import("../../types/index.js").RawValue, Datum>;
116
+ stroke: import("../../types/index.js").ChannelAccessor<Datum>;
117
+ strokeWidth: ConstantAccessor<number, Datum>;
118
+ strokeOpacity: ConstantAccessor<number, Datum>;
119
+ strokeLinejoin: ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
120
+ strokeLinecap: ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
121
+ strokeMiterlimit: ConstantAccessor<number, Datum>;
122
+ opacity: import("../../types/index.js").ChannelAccessor<Datum>;
123
+ strokeDasharray: ConstantAccessor<string, Datum>;
124
+ strokeDashoffset: ConstantAccessor<number, Datum>;
125
+ mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
126
+ clipPath: string;
127
+ imageFilter: ConstantAccessor<string, Datum>;
128
+ shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
129
+ paintOrder: ConstantAccessor<string, Datum>;
130
+ onclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
131
+ ondblclick: import("svelte/elements").MouseEventHandler<SVGPathElement>;
132
+ onmouseup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
133
+ onmousedown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
134
+ onmouseenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
135
+ onmousemove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
136
+ onmouseleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
137
+ onmouseout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
138
+ onmouseover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
139
+ onpointercancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
140
+ onpointerdown: import("svelte/elements").MouseEventHandler<SVGPathElement>;
141
+ onpointerup: import("svelte/elements").MouseEventHandler<SVGPathElement>;
142
+ onpointerenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
143
+ onpointerleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
144
+ onpointermove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
145
+ onpointerover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
146
+ onpointerout: import("svelte/elements").MouseEventHandler<SVGPathElement>;
147
+ ondrag: import("svelte/elements").MouseEventHandler<SVGPathElement>;
148
+ ondrop: import("svelte/elements").MouseEventHandler<SVGPathElement>;
149
+ ondragstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
150
+ ondragenter: import("svelte/elements").MouseEventHandler<SVGPathElement>;
151
+ ondragleave: import("svelte/elements").MouseEventHandler<SVGPathElement>;
152
+ ondragover: import("svelte/elements").MouseEventHandler<SVGPathElement>;
153
+ ondragend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
154
+ ontouchstart: import("svelte/elements").MouseEventHandler<SVGPathElement>;
155
+ ontouchmove: import("svelte/elements").MouseEventHandler<SVGPathElement>;
156
+ ontouchend: import("svelte/elements").MouseEventHandler<SVGPathElement>;
157
+ ontouchcancel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
158
+ oncontextmenu: import("svelte/elements").MouseEventHandler<SVGPathElement>;
159
+ onwheel: import("svelte/elements").MouseEventHandler<SVGPathElement>;
160
+ class: string;
161
+ style: string;
162
+ cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
163
+ }>>;
164
+ scales: PlotScales;
165
+ };
4
166
  events(): {};
5
167
  slots(): {};
6
168
  bindings(): "";
@@ -1,15 +1,77 @@
1
- import type { BaseMarkProps, BaseRectMarkProps } from '../../types/mark.js';
1
+ import type { BaseRectMarkProps } from '../../types/mark.js';
2
2
  import type { DataRecord, ScaledDataRecord } from '../../types/data.js';
3
3
  import type { UsedScales } from '../../types/index.js';
4
4
  declare class __sveltets_Render<Datum extends DataRecord> {
5
5
  props(): {
6
- datum: ScaledDataRecord<Datum_1>;
6
+ datum: ScaledDataRecord<Datum>;
7
7
  class: string | null;
8
8
  x: number;
9
9
  y: number;
10
10
  width: number;
11
11
  height: number;
12
- options: BaseRectMarkProps<Datum_1> & BaseMarkProps<Datum_1>;
12
+ options: BaseRectMarkProps<Datum> & Partial<{
13
+ filter: import("../../types/index.js").ConstantAccessor<boolean, Datum>;
14
+ facet: "auto" | "include" | "exclude";
15
+ fx: import("../../types/index.js").ChannelAccessor<Datum>;
16
+ fy: import("../../types/index.js").ChannelAccessor<Datum>;
17
+ dx: import("../../types/index.js").ConstantAccessor<number, Datum>;
18
+ dy: import("../../types/index.js").ConstantAccessor<number, Datum>;
19
+ dodgeX: import("../../transforms/dodge.js").DodgeXOptions;
20
+ dodgeY: import("../../transforms/dodge.js").DodgeYOptions;
21
+ fill: import("../../types/index.js").ChannelAccessor<Datum>;
22
+ fillOpacity: import("../../types/index.js").ConstantAccessor<number, Datum>;
23
+ sort: ((a: import("../../types/data.js").RawValue, b: import("../../types/data.js").RawValue) => number) | {
24
+ channel: string;
25
+ order?: "ascending" | "descending";
26
+ } | import("../../types/index.js").ConstantAccessor<import("../../types/data.js").RawValue, Datum>;
27
+ stroke: import("../../types/index.js").ChannelAccessor<Datum>;
28
+ strokeWidth: import("../../types/index.js").ConstantAccessor<number, Datum>;
29
+ strokeOpacity: import("../../types/index.js").ConstantAccessor<number, Datum>;
30
+ strokeLinejoin: import("../../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Datum>;
31
+ strokeLinecap: import("../../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Datum>;
32
+ strokeMiterlimit: import("../../types/index.js").ConstantAccessor<number, Datum>;
33
+ opacity: import("../../types/index.js").ChannelAccessor<Datum>;
34
+ strokeDasharray: import("../../types/index.js").ConstantAccessor<string, Datum>;
35
+ strokeDashoffset: import("../../types/index.js").ConstantAccessor<number, Datum>;
36
+ mixBlendMode: import("../../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
37
+ clipPath: string;
38
+ imageFilter: import("../../types/index.js").ConstantAccessor<string, Datum>;
39
+ shapeRendering: import("../../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
40
+ paintOrder: import("../../types/index.js").ConstantAccessor<string, Datum>;
41
+ onclick: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
42
+ ondblclick: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
43
+ onmouseup: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
44
+ onmousedown: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
45
+ onmouseenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
46
+ onmousemove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
47
+ onmouseleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
48
+ onmouseout: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
49
+ onmouseover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
50
+ onpointercancel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
51
+ onpointerdown: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
52
+ onpointerup: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
53
+ onpointerenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
54
+ onpointerleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
55
+ onpointermove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
56
+ onpointerover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
57
+ onpointerout: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
58
+ ondrag: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
59
+ ondrop: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
60
+ ondragstart: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
61
+ ondragenter: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
62
+ ondragleave: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
63
+ ondragover: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
64
+ ondragend: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
65
+ ontouchstart: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
66
+ ontouchmove: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
67
+ ontouchend: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
68
+ ontouchcancel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
69
+ oncontextmenu: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
70
+ onwheel: import("svelte/elements.js").MouseEventHandler<SVGPathElement>;
71
+ class: string;
72
+ style: string;
73
+ cursor: import("../../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Datum>;
74
+ }>;
13
75
  /**
14
76
  * By default, the `inset` property is applied to all four insets. Mark components
15
77
  * can tweak this behavior for insetTop and insetBottom by setting the
@@ -0,0 +1,58 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { StackOptions } from '../../transforms/stack';
3
+ import type { BorderRadius, ConstantAccessor, PlotScales, ScaledDataRecord } from '../../types';
4
+ type Point = [number, number];
5
+ export type WaffleOptions<T> = {
6
+ /**
7
+ * the quantity represented by each square in the waffle chart, defaults to 1
8
+ */
9
+ unit?: number;
10
+ /**
11
+ * the number of cells per row (or column); defaults to undefined
12
+ */
13
+ multiple?: number;
14
+ /**
15
+ * the separation between adjacent cells, in pixels; defaults to 1
16
+ */
17
+ gap?: number;
18
+ /**
19
+ * whether to round values to avoid partial cells; defaults to false
20
+ */
21
+ round?: boolean;
22
+ stack?: StackOptions;
23
+ borderRadius?: ConstantAccessor<BorderRadius, T>;
24
+ symbol?: Snippet<[
25
+ {
26
+ x: number;
27
+ y: number;
28
+ width: number;
29
+ height: number;
30
+ style: string | null;
31
+ styleClass: string | null;
32
+ datum: T;
33
+ }
34
+ ]>;
35
+ };
36
+ type WaffleProps = {
37
+ pattern: {
38
+ id: string;
39
+ patternUnits: 'userSpaceOnUse';
40
+ width: number;
41
+ height: number;
42
+ };
43
+ rect: {
44
+ x: number;
45
+ y: number;
46
+ width: number;
47
+ height: number;
48
+ };
49
+ path: {
50
+ fill: string;
51
+ transform: string;
52
+ d: string;
53
+ };
54
+ };
55
+ export declare function wafflePolygon(y: 'x' | 'y', options: WaffleOptions, scales: PlotScales): (d: ScaledDataRecord) => WaffleProps;
56
+ export declare function wafflePoints(i1: number, i2: number, columns: number): Point[];
57
+ export declare function maybeRound(round: boolean | ((x: number) => number) | undefined): (x: number) => number;
58
+ export {};
@@ -0,0 +1,194 @@
1
+ // A waffle is approximately a rectangular shape, but may have one or two corner
2
+ // cuts if the starting or ending value is not an even multiple of the number of
3
+ // columns (the width of the waffle in cells). We can represent any waffle by
4
+ // 8 points; below is a waffle of five columns representing the interval 2–11:
5
+ //
6
+ // 1-0
7
+ // |•7-------6
8
+ // |• • • • •|
9
+ // 2---3• • •|
10
+ // 4-----5
11
+ //
12
+ // Note that points 0 and 1 always have the same y-value, points 1 and 2 have
13
+ // the same x-value, and so on, so we don’t need to materialize the x- and y-
14
+ // values of all points. Also note that we can’t use the already-projected y-
15
+ // values because these assume that y-values are distributed linearly along y
16
+ // rather than wrapping around in columns.
17
+ //
18
+ // The corner points may be coincident. If the ending value is an even multiple
19
+ // of the number of columns, say representing the interval 2–10, then points 6,
20
+ // 7, and 0 are the same.
21
+ //
22
+ // 1-----0/7/6
23
+ // |• • • • •|
24
+ // 2---3• • •|
25
+ // 4-----5
26
+ //
27
+ // Likewise if the starting value is an even multiple, say representing the
28
+ // interval 0–10, points 2–4 are coincident.
29
+ //
30
+ // 1-----0/7/6
31
+ // |• • • • •|
32
+ // |• • • • •|
33
+ // 4/3/2-----5
34
+ //
35
+ // Waffles can also represent fractional intervals (e.g., 2.4–10.1). These
36
+ // require additional corner cuts, so the implementation below generates a few
37
+ // more points.
38
+ //
39
+ import { getPatternId } from '../../helpers/getBaseStyles';
40
+ export function wafflePolygon(y, options, scales) {
41
+ const x = y === 'y' ? 'x' : 'y';
42
+ const y1 = `${y}1`;
43
+ const y2 = `${y}2`;
44
+ const xScale = scales[x];
45
+ const yScale = scales[y];
46
+ const barwidth = xScale.fn.bandwidth();
47
+ const { unit = 1, gap = 1 } = options;
48
+ const round = maybeRound(options.round);
49
+ // The length of a unit along y in pixels.
50
+ const scale = Math.abs(yScale.fn(unit) - yScale.fn(0));
51
+ // The number of cells on each row (or column) of the waffle.
52
+ const multiple = options.multiple ?? Math.max(1, Math.floor(Math.sqrt(barwidth / scale)));
53
+ // The outer size of each square cell, in pixels, including the gap.
54
+ const cx = Math.min(barwidth / multiple, scale * multiple);
55
+ const cy = scale * multiple;
56
+ // The reference position.
57
+ const tx = (barwidth - multiple * cx) / 2;
58
+ const transform = y === 'y' ? ([x, y]) => [x * cx, -y * cy] : ([x, y]) => [y * cy, x * cx];
59
+ // const mx = typeof x0 === 'function' ? (i) => x0(i) - barwidth / 2 : () => x0;
60
+ const [ix, iy] = y === 'y' ? [0, 1] : [1, 0];
61
+ const y0 = yScale.fn(0);
62
+ const mx = -barwidth / 2;
63
+ return (d) => {
64
+ const y1val = d.resolved[y1];
65
+ const y2val = d.resolved[y2];
66
+ const P = wafflePoints(round(y1val / unit), round(y2val / unit), multiple).map(transform);
67
+ P.pop();
68
+ const id = getPatternId();
69
+ const pos = [d[x] + tx + mx, y0];
70
+ return {
71
+ pattern: {
72
+ id,
73
+ patternUnits: 'userSpaceOnUse',
74
+ width: cx,
75
+ height: cy
76
+ },
77
+ rect: {
78
+ x: gap / 2,
79
+ y: gap / 2,
80
+ width: cx - gap,
81
+ height: cy - gap
82
+ },
83
+ path: {
84
+ fill: `url(#${id})`,
85
+ transform: `translate(${pos[ix]},${pos[iy]})`,
86
+ d: `M${P.join('L')}Z`
87
+ }
88
+ };
89
+ // return `M${P.join('L')}Z`;
90
+ };
91
+ // const points = wafflePoints(i1, i2, columns);
92
+ // return dimension === 'x' ? points : points.map(([x, y]: Point): Point => [y, x]);
93
+ }
94
+ export function wafflePoints(i1, i2, columns) {
95
+ if (i2 < i1)
96
+ return wafflePoints(i2, i1, columns); // ensure i1 <= i2
97
+ if (i1 < 0)
98
+ return wafflePointsOffset(i1, i2, columns, Math.ceil(-Math.min(i1, i2) / columns)); // ensure i1 >= 0
99
+ const x1f = Math.floor(i1 % columns);
100
+ const x1c = Math.ceil(i1 % columns);
101
+ const x2f = Math.floor(i2 % columns);
102
+ const x2c = Math.ceil(i2 % columns);
103
+ const y1f = Math.floor(i1 / columns);
104
+ const y1c = Math.ceil(i1 / columns);
105
+ const y2f = Math.floor(i2 / columns);
106
+ const y2c = Math.ceil(i2 / columns);
107
+ const points = [];
108
+ if (y2c > y1c)
109
+ points.push([0, y1c]);
110
+ points.push([x1f, y1c], [x1f, y1f + (i1 % 1)], [x1c, y1f + (i1 % 1)]);
111
+ if (!(i1 % columns > columns - 1)) {
112
+ points.push([x1c, y1f]);
113
+ if (y2f > y1f)
114
+ points.push([columns, y1f]);
115
+ }
116
+ if (y2f > y1f)
117
+ points.push([columns, y2f]);
118
+ points.push([x2c, y2f], [x2c, y2f + (i2 % 1)], [x2f, y2f + (i2 % 1)]);
119
+ if (!(i2 % columns < 1)) {
120
+ points.push([x2f, y2c]);
121
+ if (y2c > y1c)
122
+ points.push([0, y2c]);
123
+ }
124
+ points.push(waffleCentroid(i1, i2, columns));
125
+ return points;
126
+ }
127
+ /**
128
+ * Compute waffle points when indices start in negative rows by applying a row offset.
129
+ * - Shifts both indices down by `k` rows (adding `k * columns`) so they are non-negative,
130
+ * delegates to `wafflePoints`, then translates the resulting points back up by `k` on y.
131
+ * - `k` is the number of rows of vertical offset applied.
132
+ */
133
+ function wafflePointsOffset(i1, i2, columns, k) {
134
+ return wafflePoints(i1 + k * columns, i2 + k * columns, columns).map(([x, y]) => [x, y - k]);
135
+ }
136
+ /**
137
+ * Centroid of the waffle region representing the interval [i1, i2).
138
+ * Chooses a strategy based on how many rows the interval spans:
139
+ * - Single row: delegate to `waffleRowCentroid`.
140
+ * - Two rows: if the projected columns overlap, return the midpoint of the overlap;
141
+ * otherwise, return the centroid of the larger partial row.
142
+ * - >= 3 rows: return the center column and halfway between the middle rows.
143
+ */
144
+ function waffleCentroid(i1, i2, columns) {
145
+ const r = Math.floor(i2 / columns) - Math.floor(i1 / columns);
146
+ return r === 0
147
+ ? // Single row
148
+ waffleRowCentroid(i1, i2, columns)
149
+ : r === 1
150
+ ? // Two incomplete rows; use the midpoint of their overlap if any, otherwise the larger row
151
+ Math.floor(i2 % columns) > Math.ceil(i1 % columns)
152
+ ? [(Math.floor(i2 % columns) + Math.ceil(i1 % columns)) / 2, Math.floor(i2 / columns)]
153
+ : i2 % columns > columns - (i1 % columns)
154
+ ? waffleRowCentroid(i2 - (i2 % columns), i2, columns)
155
+ : waffleRowCentroid(i1, columns * Math.ceil(i1 / columns), columns)
156
+ : // At least one full row; take the midpoint of all the rows that include the middle
157
+ [columns / 2, (Math.round(i1 / columns) + Math.round(i2 / columns)) / 2];
158
+ }
159
+ /**
160
+ * Centroid of a waffle segment constrained to a single row.
161
+ * Cases:
162
+ * - c === 0: both endpoints fall into the same cell; center on x, average fractional y.
163
+ * - c === 1: two adjacent partial cells; use the overlap center if > 0.5 cell,
164
+ * otherwise the center of the larger partial cell.
165
+ * - c >= 2: at least one full cell between; x is the midpoint of full cells,
166
+ * y is the row center (0.5) if there’s a full cell spanned, otherwise average fractional y.
167
+ */
168
+ function waffleRowCentroid(i1, i2, columns) {
169
+ const c = Math.floor(i2) - Math.floor(i1);
170
+ return c === 0
171
+ ? // Single cell
172
+ [Math.floor(i1 % columns) + 0.5, Math.floor(i1 / columns) + (((i1 + i2) / 2) % 1)]
173
+ : c === 1
174
+ ? // Two incomplete cells; use the overlap if large enough, otherwise use the largest
175
+ (i2 % 1) - (i1 % 1) > 0.5
176
+ ? [Math.ceil(i1 % columns), Math.floor(i2 / columns) + ((i1 % 1) + (i2 % 1)) / 2]
177
+ : i2 % 1 > 1 - (i1 % 1)
178
+ ? [Math.floor(i2 % columns) + 0.5, Math.floor(i2 / columns) + (i2 % 1) / 2]
179
+ : [Math.floor(i1 % columns) + 0.5, Math.floor(i1 / columns) + (1 + (i1 % 1)) / 2]
180
+ : // At least one full cell; take the midpoint
181
+ [
182
+ Math.ceil(i1 % columns) + Math.ceil(Math.floor(i2) - Math.ceil(i1)) / 2,
183
+ Math.floor(i1 / columns) + (i2 >= 1 + i1 ? 0.5 : ((i1 + i2) / 2) % 1)
184
+ ];
185
+ }
186
+ export function maybeRound(round) {
187
+ if (round === undefined || round === false)
188
+ return Number;
189
+ if (round === true)
190
+ return Math.round;
191
+ if (typeof round !== 'function')
192
+ throw new Error(`invalid round: ${round}`);
193
+ return round;
194
+ }
@@ -33,7 +33,6 @@ export { default as LineX } from './LineX.svelte';
33
33
  export { default as LineY } from './LineY.svelte';
34
34
  export { default as Link } from './Link.svelte';
35
35
  export { default as Pointer } from './Pointer.svelte';
36
- export { default as Vector } from './Vector.svelte';
37
36
  export { default as Rect } from './Rect.svelte';
38
37
  export { default as RectX } from './RectX.svelte';
39
38
  export { default as RectY } from './RectY.svelte';
@@ -46,6 +45,9 @@ export { default as Spike } from './Spike.svelte';
46
45
  export { default as Text } from './Text.svelte';
47
46
  export { default as TickX } from './TickX.svelte';
48
47
  export { default as TickY } from './TickY.svelte';
48
+ export { default as Vector } from './Vector.svelte';
49
+ export { default as WaffleX } from './WaffleX.svelte';
50
+ export { default as WaffleY } from './WaffleY.svelte';
49
51
  export { default as ColorLegend } from './ColorLegend.svelte';
50
52
  export { default as HTMLTooltip } from './HTMLTooltip.svelte';
51
53
  export { default as SymbolLegend } from './SymbolLegend.svelte';
@@ -33,7 +33,6 @@ export { default as LineX } from './LineX.svelte';
33
33
  export { default as LineY } from './LineY.svelte';
34
34
  export { default as Link } from './Link.svelte';
35
35
  export { default as Pointer } from './Pointer.svelte';
36
- export { default as Vector } from './Vector.svelte';
37
36
  export { default as Rect } from './Rect.svelte';
38
37
  export { default as RectX } from './RectX.svelte';
39
38
  export { default as RectY } from './RectY.svelte';
@@ -46,6 +45,9 @@ export { default as Spike } from './Spike.svelte';
46
45
  export { default as Text } from './Text.svelte';
47
46
  export { default as TickX } from './TickX.svelte';
48
47
  export { default as TickY } from './TickY.svelte';
48
+ export { default as Vector } from './Vector.svelte';
49
+ export { default as WaffleX } from './WaffleX.svelte';
50
+ export { default as WaffleY } from './WaffleY.svelte';
49
51
  // HTML marks
50
52
  export { default as ColorLegend } from './ColorLegend.svelte';
51
53
  export { default as HTMLTooltip } from './HTMLTooltip.svelte';
@@ -11,4 +11,72 @@ export type BollingerOptions = {
11
11
  };
12
12
  export declare function bollingerX(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
13
13
  export declare function bollingerY(args: TransformArg<DataRecord>, options?: BollingerOptions): TransformArg<DataRecord>;
14
- export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): any;
14
+ export declare function bollingerDim(dim: 'x' | 'y', { data, ...channels }: TransformArg<DataRecord>, options?: BollingerOptions): {
15
+ filter?: import("../types/index.js").ConstantAccessor<boolean, Record<string | symbol, import("../types/index.js").RawValue>>;
16
+ facet?: "auto" | "include" | "exclude" | undefined;
17
+ fx?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
18
+ fy?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
19
+ dx?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
20
+ dy?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
21
+ dodgeX?: import("./dodge").DodgeXOptions | undefined;
22
+ dodgeY?: import("./dodge").DodgeYOptions | undefined;
23
+ fill?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
24
+ fillOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
25
+ sort?: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
26
+ channel: string;
27
+ order?: "ascending" | "descending";
28
+ } | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Record<string | symbol, import("../types/index.js").RawValue>>;
29
+ stroke?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
30
+ strokeWidth?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
31
+ strokeOpacity?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
32
+ strokeLinejoin?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinejoin, Record<string | symbol, import("../types/index.js").RawValue>>;
33
+ strokeLinecap?: import("../types/index.js").ConstantAccessor<import("csstype").Property.StrokeLinecap, Record<string | symbol, import("../types/index.js").RawValue>>;
34
+ strokeMiterlimit?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
35
+ opacity?: import("../types/index.js").ChannelAccessor<Record<string | symbol, import("../types/index.js").RawValue>>;
36
+ strokeDasharray?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
37
+ strokeDashoffset?: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/index.js").RawValue>>;
38
+ mixBlendMode?: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/index.js").RawValue>>;
39
+ clipPath?: string | undefined;
40
+ imageFilter?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
41
+ shapeRendering?: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/index.js").RawValue>>;
42
+ paintOrder?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/index.js").RawValue>>;
43
+ onclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
44
+ ondblclick?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
45
+ onmouseup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
46
+ onmousedown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
47
+ onmouseenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
48
+ onmousemove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
49
+ onmouseleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
50
+ onmouseout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
51
+ onmouseover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
52
+ onpointercancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
53
+ onpointerdown?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
54
+ onpointerup?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
55
+ onpointerenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
56
+ onpointerleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
57
+ onpointermove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
58
+ onpointerover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
59
+ onpointerout?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
60
+ ondrag?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
61
+ ondrop?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
62
+ ondragstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
63
+ ondragenter?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
64
+ ondragleave?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
65
+ ondragover?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
66
+ ondragend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
67
+ ontouchstart?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
68
+ ontouchmove?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
69
+ ontouchend?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
70
+ ontouchcancel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
71
+ oncontextmenu?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
72
+ onwheel?: import("svelte/elements").MouseEventHandler<SVGPathElement> | undefined;
73
+ class?: string | undefined;
74
+ style?: string | undefined;
75
+ cursor?: import("../types/index.js").ConstantAccessor<import("csstype").Property.Cursor, Record<string | symbol, import("../types/index.js").RawValue>>;
76
+ data: {
77
+ __x: import("../types/index.js").RawValue;
78
+ __lo: number;
79
+ __avg: number;
80
+ __hi: number;
81
+ }[];
82
+ };
@@ -1,5 +1,8 @@
1
1
  import type { DataRecord, TransformArg } from '../types/index.js';
2
- type WithCentroid<T> = T & {};
2
+ declare const CENTROID: unique symbol;
3
+ type WithCentroid<T> = T & {
4
+ [CENTROID]: [number, number];
5
+ };
3
6
  export declare function geoCentroid<Datum extends DataRecord>({ data, ...options }: {
4
7
  data: Datum[];
5
8
  } & TransformArg<Datum>): TransformArg<WithCentroid<Datum>>;