@d3plus/core 3.0.16 → 3.1.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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88482 -2998
  3. package/es/index.js +1 -1
  4. package/es/src/charts/AreaPlot.js +1 -3
  5. package/es/src/charts/BarChart.js +1 -3
  6. package/es/src/charts/BoxWhisker.js +2 -4
  7. package/es/src/charts/BumpChart.js +4 -5
  8. package/es/src/charts/Donut.js +1 -3
  9. package/es/src/charts/Geomap.js +47 -88
  10. package/es/src/charts/LinePlot.js +1 -3
  11. package/es/src/charts/Matrix.js +27 -46
  12. package/es/src/charts/Network.js +87 -81
  13. package/es/src/charts/Pack.js +21 -34
  14. package/es/src/charts/Pie.js +12 -24
  15. package/es/src/charts/Plot.js +226 -321
  16. package/es/src/charts/Priestley.js +18 -36
  17. package/es/src/charts/Radar.js +100 -47
  18. package/es/src/charts/RadialMatrix.js +35 -47
  19. package/es/src/charts/Rings.js +99 -90
  20. package/es/src/charts/Sankey.js +85 -75
  21. package/es/src/charts/StackedArea.js +1 -3
  22. package/es/src/charts/Tree.js +27 -28
  23. package/es/src/charts/Treemap.js +117 -71
  24. package/es/src/charts/Viz.js +296 -492
  25. package/es/src/charts/drawSteps/drawAttribution.js +1 -1
  26. package/es/src/charts/drawSteps/drawBack.js +1 -2
  27. package/es/src/charts/drawSteps/drawColorScale.js +1 -2
  28. package/es/src/charts/drawSteps/drawLegend.js +8 -10
  29. package/es/src/charts/drawSteps/drawSubtitle.js +1 -3
  30. package/es/src/charts/drawSteps/drawTimeline.js +12 -9
  31. package/es/src/charts/drawSteps/drawTitle.js +1 -3
  32. package/es/src/charts/drawSteps/drawTotal.js +1 -3
  33. package/es/src/charts/drawSteps/zoomControls.js +19 -21
  34. package/es/src/charts/events/click.legend.js +2 -3
  35. package/es/src/charts/events/click.shape.js +2 -4
  36. package/es/src/charts/events/mouseenter.js +7 -8
  37. package/es/src/charts/events/mouseleave.js +1 -3
  38. package/es/src/charts/events/mousemove.legend.js +3 -4
  39. package/es/src/charts/events/mousemove.shape.js +2 -4
  40. package/es/src/charts/events/touchstart.body.js +1 -1
  41. package/es/src/charts/helpers/matrixData.js +11 -4
  42. package/es/src/charts/helpers/tileAttributions.js +2 -1
  43. package/es/src/charts/plotBuffers/Bar.js +55 -12
  44. package/es/src/charts/plotBuffers/Box.js +55 -12
  45. package/es/src/charts/plotBuffers/Circle.js +9 -11
  46. package/es/src/charts/plotBuffers/Line.js +4 -6
  47. package/es/src/charts/plotBuffers/Rect.js +10 -12
  48. package/es/src/charts/plotBuffers/discreteBuffer.js +4 -2
  49. package/es/src/charts/plotBuffers/numericBuffer.js +7 -6
  50. package/es/src/components/Axis.js +298 -426
  51. package/es/src/components/AxisBottom.js +1 -3
  52. package/es/src/components/AxisLeft.js +1 -3
  53. package/es/src/components/AxisRight.js +1 -3
  54. package/es/src/components/AxisTop.js +1 -3
  55. package/es/src/components/ColorScale.js +80 -197
  56. package/es/src/components/Legend.js +82 -135
  57. package/es/src/components/Message.js +27 -19
  58. package/es/src/components/TextBox.js +106 -262
  59. package/es/src/components/Timeline.js +88 -155
  60. package/es/src/components/Tooltip.js +301 -330
  61. package/es/src/shapes/Area.js +95 -74
  62. package/es/src/shapes/Bar.js +46 -86
  63. package/es/src/shapes/Box.js +104 -118
  64. package/es/src/shapes/Circle.js +29 -30
  65. package/es/src/shapes/Image.js +44 -102
  66. package/es/src/shapes/Line.js +74 -40
  67. package/es/src/shapes/Path.js +23 -25
  68. package/es/src/shapes/Rect.js +29 -41
  69. package/es/src/shapes/Shape.js +146 -363
  70. package/es/src/shapes/Whisker.js +89 -90
  71. package/es/src/utils/AccessorFn.js +4 -0
  72. package/es/src/utils/BaseClass.js +53 -82
  73. package/es/src/utils/D3plusConfig.js +1 -0
  74. package/es/src/utils/RESET.js +2 -4
  75. package/es/src/utils/accessor.js +4 -5
  76. package/es/src/utils/configPrep.js +13 -12
  77. package/es/src/utils/constant.js +2 -3
  78. package/es/src/utils/getProp.js +4 -4
  79. package/es/src/utils/index.js +0 -1
  80. package/package.json +29 -22
  81. package/types/index.d.ts +5 -0
  82. package/types/src/charts/AreaPlot.d.ts +16 -0
  83. package/types/src/charts/BarChart.d.ts +16 -0
  84. package/types/src/charts/BoxWhisker.d.ts +11 -0
  85. package/types/src/charts/BumpChart.d.ts +36 -0
  86. package/types/src/charts/Donut.d.ts +11 -0
  87. package/types/src/charts/Geomap.d.ts +120 -0
  88. package/types/src/charts/LinePlot.d.ts +15 -0
  89. package/types/src/charts/Matrix.d.ts +74 -0
  90. package/types/src/charts/Network.d.ts +78 -0
  91. package/types/src/charts/Pack.d.ts +47 -0
  92. package/types/src/charts/Pie.d.ts +44 -0
  93. package/types/src/charts/Plot.d.ts +199 -0
  94. package/types/src/charts/Priestley.d.ts +37 -0
  95. package/types/src/charts/Radar.d.ts +38 -0
  96. package/types/src/charts/RadialMatrix.d.ts +78 -0
  97. package/types/src/charts/Rings.d.ts +74 -0
  98. package/types/src/charts/Sankey.d.ts +81 -0
  99. package/types/src/charts/StackedArea.d.ts +14 -0
  100. package/types/src/charts/Tree.d.ts +33 -0
  101. package/types/src/charts/Treemap.d.ts +51 -0
  102. package/types/src/charts/Viz.d.ts +402 -0
  103. package/types/src/charts/drawSteps/drawAttribution.d.ts +7 -0
  104. package/types/src/charts/drawSteps/drawBack.d.ts +6 -0
  105. package/types/src/charts/drawSteps/drawColorScale.d.ts +6 -0
  106. package/types/src/charts/drawSteps/drawLegend.d.ts +12 -0
  107. package/types/src/charts/drawSteps/drawSubtitle.d.ts +7 -0
  108. package/types/src/charts/drawSteps/drawTimeline.d.ts +7 -0
  109. package/types/src/charts/drawSteps/drawTitle.d.ts +7 -0
  110. package/types/src/charts/drawSteps/drawTotal.d.ts +7 -0
  111. package/types/src/charts/drawSteps/zoomControls.d.ts +7 -0
  112. package/types/src/charts/events/click.legend.d.ts +8 -0
  113. package/types/src/charts/events/click.shape.d.ts +8 -0
  114. package/types/src/charts/events/mouseenter.d.ts +8 -0
  115. package/types/src/charts/events/mouseleave.d.ts +8 -0
  116. package/types/src/charts/events/mousemove.legend.d.ts +9 -0
  117. package/types/src/charts/events/mousemove.shape.d.ts +9 -0
  118. package/types/src/charts/events/touchstart.body.d.ts +7 -0
  119. package/types/src/charts/helpers/matrixData.d.ts +11 -0
  120. package/types/src/charts/helpers/tileAttributions.d.ts +6 -0
  121. package/types/src/charts/index.d.ts +21 -0
  122. package/types/src/charts/plotBuffers/Bar.d.ts +16 -0
  123. package/types/src/charts/plotBuffers/Box.d.ts +16 -0
  124. package/types/src/charts/plotBuffers/Circle.d.ts +20 -0
  125. package/types/src/charts/plotBuffers/Line.d.ts +16 -0
  126. package/types/src/charts/plotBuffers/Rect.d.ts +19 -0
  127. package/types/src/charts/plotBuffers/discreteBuffer.d.ts +7 -0
  128. package/types/src/charts/plotBuffers/numericBuffer.d.ts +5 -0
  129. package/types/src/components/Axis.d.ts +309 -0
  130. package/types/src/components/AxisBottom.d.ts +11 -0
  131. package/types/src/components/AxisLeft.d.ts +11 -0
  132. package/types/src/components/AxisRight.d.ts +11 -0
  133. package/types/src/components/AxisTop.d.ts +11 -0
  134. package/types/src/components/ColorScale.d.ts +208 -0
  135. package/types/src/components/Legend.d.ts +157 -0
  136. package/types/src/components/Message.d.ts +40 -0
  137. package/types/src/components/TextBox.d.ts +278 -0
  138. package/types/src/components/Timeline.d.ts +157 -0
  139. package/types/src/components/Tooltip.d.ts +297 -0
  140. package/types/src/components/index.d.ts +11 -0
  141. package/types/src/shapes/Area.d.ts +81 -0
  142. package/types/src/shapes/Bar.d.ts +104 -0
  143. package/types/src/shapes/Box.d.ts +121 -0
  144. package/types/src/shapes/Circle.d.ts +44 -0
  145. package/types/src/shapes/Image.d.ts +124 -0
  146. package/types/src/shapes/Line.d.ts +48 -0
  147. package/types/src/shapes/Path.d.ts +38 -0
  148. package/types/src/shapes/Rect.d.ts +54 -0
  149. package/types/src/shapes/Shape.d.ts +378 -0
  150. package/types/src/shapes/Whisker.d.ts +96 -0
  151. package/types/src/shapes/index.d.ts +10 -0
  152. package/types/src/utils/AccessorFn.d.ts +6 -0
  153. package/types/src/utils/BaseClass.d.ts +76 -0
  154. package/types/src/utils/D3plusConfig.d.ts +164 -0
  155. package/types/src/utils/RESET.d.ts +3 -0
  156. package/types/src/utils/accessor.d.ts +13 -0
  157. package/types/src/utils/configPrep.d.ts +28 -0
  158. package/types/src/utils/constant.d.ts +11 -0
  159. package/types/src/utils/getProp.d.ts +9 -0
  160. package/types/src/utils/index.d.ts +8 -0
  161. package/umd/d3plus-core.full.js +20126 -18700
  162. package/umd/d3plus-core.full.js.map +1 -1
  163. package/umd/d3plus-core.full.min.js +2919 -5393
  164. package/umd/d3plus-core.js +1919 -4073
  165. package/umd/d3plus-core.js.map +1 -1
  166. package/umd/d3plus-core.min.js +1604 -3936
  167. package/es/src/utils/uuid.js +0 -13
@@ -0,0 +1,297 @@
1
+ import type { VirtualElement } from "@floating-ui/dom";
2
+ import type { DataPoint } from "@d3plus/data";
3
+ import { BaseClass } from "../utils/index.js";
4
+ /**
5
+ Creates HTML tooltips in the body of a webpage.
6
+ */
7
+ export default class Tooltip extends BaseClass {
8
+ _arrow: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
9
+ _arrowStyle: Record<string, string>;
10
+ _background: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
11
+ _body: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
12
+ _bodyStyle: Record<string, string>;
13
+ _border: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
14
+ _borderRadius: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
15
+ _className: string;
16
+ _data: DataPoint[];
17
+ _footer: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
18
+ _footerStyle: Record<string, string>;
19
+ _height: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
20
+ _id: (d: DataPoint, i: number) => string;
21
+ _offset: (d: DataPoint, i?: number) => number;
22
+ _padding: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
23
+ _pointerEvents: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
24
+ _tooltipRefs: Record<string, {
25
+ reference: VirtualElement | HTMLElement;
26
+ arrowEl: HTMLElement;
27
+ tooltip: HTMLElement;
28
+ arrowHeight: number;
29
+ arrowDistance: number;
30
+ }>;
31
+ _position: (d: DataPoint, i?: number) => number[] | HTMLElement;
32
+ _tableStyle: Record<string, string>;
33
+ _tbody: unknown[];
34
+ _tbodyStyle: Record<string, string>;
35
+ _thead: unknown[];
36
+ _theadStyle: Record<string, string>;
37
+ _title: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
38
+ _titleStyle: Record<string, string>;
39
+ _tooltipStyle: Record<string, string>;
40
+ _trStyle: Record<string, unknown>;
41
+ _tdStyle: Record<string, string>;
42
+ _maxWidth: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
43
+ _minWidth: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
44
+ _width: (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
45
+ /**
46
+ Invoked when creating a new class instance, and sets any default parameters.
47
+ @private
48
+ */
49
+ constructor();
50
+ /**
51
+ The inner return object and draw function that gets assigned the public methods.
52
+ @private
53
+ */
54
+ render(callback?: (...args: unknown[]) => unknown): this;
55
+ /**
56
+ The inner HTML content of the arrow element, empty by default.
57
+
58
+ @example <caption>default accessor</caption>
59
+ function value(d) {
60
+ return d.arrow || "";
61
+ }
62
+ */
63
+ arrow(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
64
+ arrow(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
65
+ /**
66
+ CSS styles applied to the arrow element.
67
+
68
+ @example <caption>default styles</caption>
69
+ {
70
+ "content": "",
71
+ "border-width": "10px",
72
+ "border-style": "solid",
73
+ "border-color": "rgba(255, 255, 255, 0.75) transparent transparent transparent",
74
+ "position": "absolute"
75
+ }
76
+ */
77
+ arrowStyle(): Record<string, string>;
78
+ arrowStyle(_: Record<string, string>): this;
79
+ /**
80
+ The background color accessor for each tooltip.
81
+ */
82
+ background(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
83
+ background(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
84
+ /**
85
+ The body content accessor for each tooltip.
86
+
87
+ @example <caption>default accessor</caption>
88
+ function value(d) {
89
+ return d.body || "";
90
+ }
91
+ */
92
+ body(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
93
+ body(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
94
+ /**
95
+ CSS styles applied to the body element.
96
+
97
+ @example <caption>default styles</caption>
98
+ {
99
+ "font-size": "12px",
100
+ "font-weight": "400"
101
+ }
102
+ */
103
+ bodyStyle(): Record<string, string>;
104
+ bodyStyle(_: Record<string, string>): this;
105
+ /**
106
+ The border accessor for each tooltip.
107
+ */
108
+ border(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
109
+ border(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
110
+ /**
111
+ The border-radius accessor for each tooltip.
112
+ */
113
+ borderRadius(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
114
+ borderRadius(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
115
+ /**
116
+ The CSS class name applied to the tooltip container.
117
+ */
118
+ className(): string;
119
+ className(_: string): this;
120
+ /**
121
+ The data array used to create tooltips.
122
+ */
123
+ data(): DataPoint[];
124
+ data(_: DataPoint[]): this;
125
+ /**
126
+ The footer content accessor for each tooltip.
127
+
128
+ @example <caption>default accessor</caption>
129
+ function value(d) {
130
+ return d.footer || "";
131
+ }
132
+ */
133
+ footer(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
134
+ footer(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
135
+ /**
136
+ CSS styles applied to the footer element.
137
+
138
+ @example <caption>default styles</caption>
139
+ {
140
+ "font-size": "12px",
141
+ "font-weight": "400"
142
+ }
143
+ */
144
+ footerStyle(): Record<string, string>;
145
+ footerStyle(_: Record<string, string>): this;
146
+ /**
147
+ The height accessor for each tooltip.
148
+ */
149
+ height(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
150
+ height(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
151
+ /**
152
+ The unique id accessor for each tooltip.
153
+
154
+ @example <caption>default accessor</caption>
155
+ function value(d, i) {
156
+ return d.id || "" + i;
157
+ }
158
+ */
159
+ id(): (d: DataPoint, i: number) => string;
160
+ id(_: ((d: DataPoint, i: number) => string) | string): this;
161
+ /**
162
+ The pixel offset between the tooltip and its anchor point.
163
+ */
164
+ offset(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
165
+ offset(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | number): this;
166
+ /**
167
+ The inner padding of each tooltip.
168
+ */
169
+ padding(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
170
+ padding(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
171
+ /**
172
+ The pointer-events CSS property for each tooltip.
173
+ */
174
+ pointerEvents(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
175
+ pointerEvents(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
176
+ /**
177
+ The position of each tooltip. Can be an HTMLElement to anchor to, a selection string, or coordinate points in reference to the client viewport (not the overall page).
178
+
179
+ @example <caption>default accessor</caption>
180
+ function value(d) {
181
+ return [d.x, d.y];
182
+ }
183
+ */
184
+ position(): (d: DataPoint, i?: number) => number[] | HTMLElement;
185
+ position(_: ((d: DataPoint, i?: number) => number[] | HTMLElement) | number[] | HTMLElement | string): this;
186
+ /**
187
+ CSS styles applied to the table element.
188
+
189
+ @example <caption>default styles</caption>
190
+ {
191
+ "border-collapse": "collapse",
192
+ "border-spacing": "0",
193
+ "width": "100%"
194
+ }
195
+ */
196
+ tableStyle(): Record<string, string>;
197
+ tableStyle(_: Record<string, string>): this;
198
+ /**
199
+ The table body contents as an array of functions or strings.
200
+ */
201
+ tbody(): unknown[];
202
+ tbody(_: unknown[]): this;
203
+ /**
204
+ CSS styles applied to the table body element.
205
+
206
+ @example <caption>default styles</caption>
207
+ {
208
+ "font-size": "12px",
209
+ "font-weight": "600",
210
+ "text-align": "center"
211
+ }
212
+ */
213
+ tbodyStyle(): Record<string, string>;
214
+ tbodyStyle(_: Record<string, string>): this;
215
+ /**
216
+ The table head contents as an array of functions or strings.
217
+ */
218
+ thead(): unknown[];
219
+ thead(_: unknown[]): this;
220
+ /**
221
+ CSS styles applied to the table head element.
222
+
223
+ @example <caption>default styles</caption>
224
+ {
225
+ "font-size": "12px",
226
+ "font-weight": "600",
227
+ "text-align": "center"
228
+ }
229
+ */
230
+ theadStyle(): Record<string, string>;
231
+ theadStyle(_: Record<string, string>): this;
232
+ /**
233
+ The title content accessor for each tooltip.
234
+
235
+ @example <caption>default accessor</caption>
236
+ function value(d) {
237
+ return d.title || "";
238
+ }
239
+ */
240
+ title(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
241
+ title(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
242
+ /**
243
+ CSS styles applied to the title element.
244
+
245
+ @example <caption>default styles</caption>
246
+ {
247
+ "font-size": "14px",
248
+ "font-weight": "600",
249
+ "padding-bottom": "5px"
250
+ }
251
+ */
252
+ titleStyle(): Record<string, string>;
253
+ titleStyle(_: Record<string, string>): this;
254
+ /**
255
+ Overall CSS styles applied to the tooltip container.
256
+
257
+ @example <caption>default styles</caption>
258
+ {
259
+ "font-family": "'Inter', 'Helvetica Neue', 'HelveticaNeue', 'Helvetica', 'Arial', sans-serif",
260
+ "font-size": "14px",
261
+ "font-weight": "600",
262
+ "padding-bottom": "5px"
263
+ }
264
+ */
265
+ tooltipStyle(): Record<string, string>;
266
+ tooltipStyle(_: Record<string, string>): this;
267
+ /**
268
+ An object with CSS keys and values to be applied to all <tr> elements inside of each <tbody>.
269
+
270
+ @example <caption>default styles</caption>
271
+ {
272
+ "border-top": "1px solid rgba(0, 0, 0, 0.1)"
273
+ }
274
+ */
275
+ trStyle(): Record<string, unknown>;
276
+ trStyle(_: Record<string, unknown>): this;
277
+ /**
278
+ An object with CSS keys and values to be applied to all <td> elements inside of each <tr>.
279
+ */
280
+ tdStyle(): Record<string, string>;
281
+ tdStyle(_: Record<string, string>): this;
282
+ /**
283
+ The max-width accessor for each tooltip.
284
+ */
285
+ maxWidth(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
286
+ maxWidth(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
287
+ /**
288
+ The min-width accessor for each tooltip.
289
+ */
290
+ minWidth(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
291
+ minWidth(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
292
+ /**
293
+ The width accessor for each tooltip.
294
+ */
295
+ width(): (d: DataPoint, i?: number) => DataPoint[keyof DataPoint];
296
+ width(_: ((d: DataPoint, i?: number) => DataPoint[keyof DataPoint]) | string): this;
297
+ }
@@ -0,0 +1,11 @@
1
+ export { default as Axis } from "./Axis.js";
2
+ export { default as AxisBottom } from "./AxisBottom.js";
3
+ export { default as AxisLeft } from "./AxisLeft.js";
4
+ export { default as AxisRight } from "./AxisRight.js";
5
+ export { default as AxisTop } from "./AxisTop.js";
6
+ export { default as ColorScale } from "./ColorScale.js";
7
+ export { default as Legend } from "./Legend.js";
8
+ export { default as Message } from "./Message.js";
9
+ export { default as TextBox } from "./TextBox.js";
10
+ export { default as Timeline } from "./Timeline.js";
11
+ export { default as Tooltip } from "./Tooltip.js";
@@ -0,0 +1,81 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { AccessorFn } from "../utils/index.js";
3
+ import Shape, { type ShapeAes } from "./Shape.js";
4
+ /**
5
+ Creates SVG areas based on an array of data.
6
+ */
7
+ export default class Area extends Shape {
8
+ _curve: AccessorFn;
9
+ _defined: (d: DataPoint) => boolean;
10
+ _labelBounds: ((d: DataPoint, i: number, aes: ShapeAes) => Record<string, unknown> | null | false) | null;
11
+ _labelConfig: Record<string, unknown>;
12
+ _name: string;
13
+ _x: AccessorFn;
14
+ _x0: AccessorFn;
15
+ _x1: AccessorFn | null;
16
+ _y: AccessorFn;
17
+ _y0: AccessorFn;
18
+ _y1: AccessorFn | null;
19
+ _path: Record<string, unknown>;
20
+ /**
21
+ Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
22
+ @private
23
+ */
24
+ constructor();
25
+ /**
26
+ Given a specific data point and index, returns the aesthetic properties of the shape.
27
+ @param data point*
28
+ @param index @private
29
+ */
30
+ _aes(d: DataPoint): ShapeAes;
31
+ /**
32
+ Filters/manipulates the data array before binding each point to an SVG group.
33
+ @param data @private
34
+ */
35
+ _dataFilter(data: DataPoint[]): DataPoint[];
36
+ /**
37
+ Draws the area polygons.
38
+ @param callback Optional callback invoked after rendering completes.
39
+ */
40
+ render(callback?: () => void): this;
41
+ /**
42
+ The d3 curve function used to interpolate the area.
43
+ */
44
+ curve(): AccessorFn;
45
+ curve(_: AccessorFn | string): this;
46
+ /**
47
+ An accessor function that determines whether a data point is defined (not a gap in the area).
48
+ */
49
+ defined(): (d: DataPoint) => boolean;
50
+ defined(_: (d: DataPoint) => boolean): this;
51
+ /**
52
+ The x position accessor. Also sets x0 to the same value.
53
+ */
54
+ x(): AccessorFn;
55
+ x(_: AccessorFn | number): this;
56
+ /**
57
+ The x0 (left edge) position accessor for the area.
58
+ */
59
+ x0(): AccessorFn;
60
+ x0(_: AccessorFn | number): this;
61
+ /**
62
+ The x1 (right edge) position accessor for the area.
63
+ */
64
+ x1(): AccessorFn | null;
65
+ x1(_: AccessorFn | number | null): this;
66
+ /**
67
+ The y position accessor. Also sets y0 to the same value.
68
+ */
69
+ y(): AccessorFn;
70
+ y(_: AccessorFn | number): this;
71
+ /**
72
+ The y0 (top edge) position accessor for the area.
73
+ */
74
+ y0(): AccessorFn;
75
+ y0(_: AccessorFn | number): this;
76
+ /**
77
+ The y1 (bottom edge) position accessor for the area.
78
+ */
79
+ y1(): AccessorFn | null;
80
+ y1(_: AccessorFn | number | null): this;
81
+ }
@@ -0,0 +1,104 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { D3Selection } from "@d3plus/dom";
3
+ import type { AccessorFn } from "../utils/index.js";
4
+ import Shape, { type ShapeAes } from "./Shape.js";
5
+ /**
6
+ Creates SVG areas based on an array of data.
7
+ */
8
+ export default class Bar extends Shape {
9
+ _height: AccessorFn;
10
+ _labelBounds: ((d: DataPoint, i: number, aes: ShapeAes) => Record<string, unknown> | null | false) | null;
11
+ _name: string;
12
+ _width: AccessorFn;
13
+ _x: AccessorFn;
14
+ _x0: AccessorFn;
15
+ _x1: AccessorFn | null;
16
+ _y: AccessorFn;
17
+ _y0: AccessorFn;
18
+ _y1: AccessorFn | null;
19
+ /**
20
+ Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
21
+ @private
22
+ */
23
+ constructor();
24
+ /**
25
+ Draws the bars.
26
+ @param callback Optional callback invoked after rendering completes.
27
+ */
28
+ render(callback?: () => void): this;
29
+ /**
30
+ Given a specific data point and index, returns the aesthetic properties of the shape.
31
+ @param data point*
32
+ @param index @private
33
+ */
34
+ _aes(d: DataPoint, i: number): ShapeAes;
35
+ /**
36
+ Provides the default positioning to the <rect> elements.
37
+ @param elem @private
38
+ */
39
+ _applyPosition(elem: D3Selection): void;
40
+ /**
41
+ Calculates the height of the <rect> by assessing the x and y properties.
42
+
43
+ @private
44
+ */
45
+ _getHeight(d: DataPoint, i: number): number;
46
+ /**
47
+ Calculates the width of the <rect> by assessing the x and y properties.
48
+
49
+ @private
50
+ */
51
+ _getWidth(d: DataPoint, i: number): number;
52
+ /**
53
+ Calculates the x of the <rect> by assessing the x and width properties.
54
+
55
+ @private
56
+ */
57
+ _getX(d: DataPoint, i: number): number;
58
+ /**
59
+ Calculates the y of the <rect> by assessing the y and height properties.
60
+
61
+ @private
62
+ */
63
+ _getY(d: DataPoint, i: number): number;
64
+ /**
65
+ The height accessor for each bar.
66
+
67
+ @example
68
+ function(d) {
69
+ return d.height;
70
+ }
71
+ */
72
+ height(): AccessorFn;
73
+ height(_: AccessorFn | number): this;
74
+ /**
75
+ The width accessor for each bar.
76
+
77
+ @example
78
+ function(d) {
79
+ return d.width;
80
+ }
81
+ */
82
+ width(): AccessorFn;
83
+ width(_: AccessorFn | number): this;
84
+ /**
85
+ The x0 (left edge) position accessor for each bar.
86
+ */
87
+ x0(): AccessorFn;
88
+ x0(_: AccessorFn | number): this;
89
+ /**
90
+ The x1 (right edge) position accessor for each bar.
91
+ */
92
+ x1(): AccessorFn | null;
93
+ x1(_: AccessorFn | number | null): this;
94
+ /**
95
+ The y0 (top edge) position accessor for each bar.
96
+ */
97
+ y0(): AccessorFn;
98
+ y0(_: AccessorFn | number): this;
99
+ /**
100
+ The y1 (bottom edge) position accessor for each bar.
101
+ */
102
+ y1(): AccessorFn | null;
103
+ y1(_: AccessorFn | number | null): this;
104
+ }
@@ -0,0 +1,121 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { D3Selection } from "@d3plus/dom";
3
+ import { BaseClass } from "../utils/index.js";
4
+ import type { AccessorFn } from "../utils/index.js";
5
+ import Circle from "./Circle.js";
6
+ import Rect from "./Rect.js";
7
+ import Whisker from "./Whisker.js";
8
+ /**
9
+ Creates SVG box based on an array of data.
10
+ */
11
+ export default class Box extends BaseClass {
12
+ _medianConfig: Record<string, unknown>;
13
+ _orient: AccessorFn;
14
+ _outlier: AccessorFn;
15
+ _outlierConfig: Record<string, unknown>;
16
+ _rectConfig: Record<string, unknown>;
17
+ _rectWidth: AccessorFn;
18
+ _whiskerConfig: Record<string, unknown>;
19
+ _whiskerMode: (string | number)[];
20
+ _x: AccessorFn;
21
+ _y: AccessorFn;
22
+ _data: DataPoint[];
23
+ _select: D3Selection;
24
+ _box: Rect;
25
+ _median: Rect;
26
+ _whisker: Whisker;
27
+ _whiskerEndpoint: (Circle | Rect)[];
28
+ _duration: number;
29
+ /**
30
+ Invoked when creating a new class instance, and overrides any default parameters inherited from BaseClass.
31
+ @private
32
+ */
33
+ constructor();
34
+ /**
35
+ Draws the Box.
36
+ */
37
+ render(): this;
38
+ /**
39
+ The active highlight state for all sub-shapes in this Box.
40
+ */
41
+ active(_: ((d: DataPoint, i: number) => boolean) | null): void;
42
+ /**
43
+ The data array used to create shapes.
44
+ */
45
+ data(): DataPoint[];
46
+ data(_: DataPoint[]): this;
47
+ /**
48
+ The hover highlight state for all sub-shapes in this Box.
49
+ */
50
+ hover(_: ((d: DataPoint, i: number) => boolean) | null): void;
51
+ /**
52
+ Configuration object for the median line.
53
+ */
54
+ medianConfig(): Record<string, unknown>;
55
+ medianConfig(_: Record<string, unknown>): this;
56
+ /**
57
+ The orientation of the box shape.
58
+ */
59
+ orient(): AccessorFn;
60
+ orient(_: AccessorFn | string): this;
61
+ /**
62
+ Whether to show outlier points.
63
+ */
64
+ outlier(): AccessorFn;
65
+ outlier(_: AccessorFn | string): this;
66
+ /**
67
+ Configuration object for each outlier point.
68
+ */
69
+ outlierConfig(): Record<string, unknown>;
70
+ outlierConfig(_: Record<string, unknown>): this;
71
+ /**
72
+ Configuration object for the rect shape.
73
+ */
74
+ rectConfig(): Record<string, unknown>;
75
+ rectConfig(_: Record<string, unknown>): this;
76
+ /**
77
+ The width accessor for each box.
78
+
79
+ @example
80
+ function(d) {
81
+ return d.width;
82
+ }
83
+ */
84
+ rectWidth(): AccessorFn;
85
+ rectWidth(_: AccessorFn | number): this;
86
+ /**
87
+ The SVG container element for this visualization. 3 selector or DOM element.
88
+ */
89
+ select(): D3Selection;
90
+ select(_: string | HTMLElement | SVGElement | null): this;
91
+ /**
92
+ Configuration object for the whisker.
93
+ */
94
+ whiskerConfig(): Record<string, unknown>;
95
+ whiskerConfig(_: Record<string, unknown>): this;
96
+ /**
97
+ Determines the value used for each whisker. Can be passed a single value to apply for both whiskers, or an Array of 2 values for the lower and upper whiskers (in that order). Accepted values are `"tukey"`, `"extent"`, or a Number representing a quantile.
98
+ */
99
+ whiskerMode(): (string | number)[];
100
+ whiskerMode(_: (string | number)[] | string | number): this;
101
+ /**
102
+ The x position accessor for each box.
103
+
104
+ @example
105
+ function(d) {
106
+ return d.x;
107
+ }
108
+ */
109
+ x(): AccessorFn;
110
+ x(_: AccessorFn | number): this;
111
+ /**
112
+ The y position accessor for each box.
113
+
114
+ @example
115
+ function(d) {
116
+ return d.y;
117
+ }
118
+ */
119
+ y(): AccessorFn;
120
+ y(_: AccessorFn | number): this;
121
+ }
@@ -0,0 +1,44 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { D3Selection } from "@d3plus/dom";
3
+ import type { AccessorFn } from "../utils/index.js";
4
+ import Shape, { type ShapeAes } from "./Shape.js";
5
+ /**
6
+ Creates SVG circles based on an array of data.
7
+ */
8
+ export default class Circle extends Shape {
9
+ _labelBounds: ((d: DataPoint, i: number, aes: ShapeAes) => Record<string, unknown> | null | false) | null;
10
+ _labelConfig: Record<string, unknown>;
11
+ _name: string;
12
+ _r: AccessorFn;
13
+ /**
14
+ Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
15
+ @private
16
+ */
17
+ constructor();
18
+ /**
19
+ Provides the default positioning to the <rect> elements.
20
+ @private
21
+ */
22
+ _applyPosition(elem: D3Selection): void;
23
+ /**
24
+ Draws the circles.
25
+ @param callback Optional callback invoked after rendering completes.
26
+ */
27
+ render(callback?: () => void): this;
28
+ /**
29
+ Given a specific data point and index, returns the aesthetic properties of the shape.
30
+ @param data point*
31
+ @param index @private
32
+ */
33
+ _aes(d: DataPoint, i: number): ShapeAes;
34
+ /**
35
+ The radius accessor for each circle.
36
+
37
+ @example
38
+ function(d) {
39
+ return d.r;
40
+ }
41
+ */
42
+ r(): AccessorFn;
43
+ r(_: AccessorFn | number): this;
44
+ }