@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,157 @@
1
+ import type { DataPoint } from "@d3plus/data";
2
+ import type { D3Selection } from "@d3plus/dom";
3
+ import { TextBox } from "../components/index.js";
4
+ import { BaseClass } from "../utils/index.js";
5
+ /**
6
+ Creates an SVG legend based on an array of data.
7
+ */
8
+ export default class Legend extends BaseClass {
9
+ _titleClass: TextBox;
10
+ _align: string;
11
+ _data: DataPoint[];
12
+ _direction: string;
13
+ _duration: number;
14
+ _height: number;
15
+ _id: (d: DataPoint, i?: number) => unknown;
16
+ _label: (d: DataPoint, i?: number) => unknown;
17
+ _lineData: Record<string, unknown>[];
18
+ _outerBounds: Record<string, number>;
19
+ _padding: number;
20
+ _shape: (d: DataPoint, i?: number) => unknown;
21
+ _select: D3Selection;
22
+ _shapes: unknown[];
23
+ _shapeConfig: Record<string, unknown>;
24
+ _titleConfig: Record<string, unknown>;
25
+ _verticalAlign: string;
26
+ _width: number;
27
+ _rtl: boolean;
28
+ _group: D3Selection;
29
+ _titleGroup: D3Selection;
30
+ _shapeGroup: D3Selection;
31
+ _titleHeight: number;
32
+ _titleWidth: number;
33
+ _title: string | undefined;
34
+ _wrapLines: (() => void) | undefined;
35
+ _wrapRows: (() => void) | undefined;
36
+ /**
37
+ Invoked when creating a new class instance, and sets any default parameters.
38
+ @private
39
+ */
40
+ constructor();
41
+ /**
42
+ @param key The configuration key.
43
+ @param d The data point.
44
+ @param i The data index.
45
+ @private
46
+ */
47
+ _fetchConfig(key: string, d: DataPoint, i: number): unknown;
48
+ /**
49
+ @param row The legend row data.
50
+ @private
51
+ */
52
+ _rowHeight(row: Record<string, unknown>[]): number;
53
+ /**
54
+ @param row The legend row data.
55
+ @private
56
+ */
57
+ _rowWidth(row: Record<string, unknown>[]): number;
58
+ /**
59
+ Renders the current Legend to the page.
60
+ @param callback Optional callback invoked after rendering completes.
61
+ */
62
+ render(callback?: (...args: unknown[]) => unknown): this;
63
+ /**
64
+ The active method for all shapes.
65
+ */
66
+ active(_: unknown): this;
67
+ /**
68
+ The horizontal alignment.
69
+ */
70
+ align(): string;
71
+ align(_: string): this;
72
+ /**
73
+ The data array used to create shapes. A shape key will be drawn for each object in the array.
74
+ */
75
+ data(): DataPoint[];
76
+ data(_: DataPoint[]): this;
77
+ /**
78
+ The flow direction of the legend items.
79
+ */
80
+ direction(): string;
81
+ direction(_: string): this;
82
+ /**
83
+ Transition duration of the legend.
84
+ */
85
+ duration(): number;
86
+ duration(_: number): this;
87
+ /**
88
+ Overall height of the legend.
89
+ */
90
+ height(): number;
91
+ height(_: number): this;
92
+ /**
93
+ The hover method for all shapes.
94
+ */
95
+ hover(_: unknown): this;
96
+ /**
97
+ The unique id accessor for each legend entry.
98
+
99
+ @example
100
+ function value(d) {
101
+ return d.id;
102
+ }
103
+ */
104
+ id(): (d: DataPoint, i?: number) => unknown;
105
+ id(_: (d: DataPoint, i?: number) => unknown): this;
106
+ /**
107
+ The label accessor for each legend entry. Uses the id accessor by default.
108
+ */
109
+ label(): (d: DataPoint, i?: number) => unknown;
110
+ label(_: ((d: DataPoint, i?: number) => unknown) | unknown): this;
111
+ /**
112
+ Returns the outer bounds of the legend content. Must be called after rendering.
113
+ @example
114
+ {"width": 180, "height": 24, "x": 10, "y": 20}
115
+ */
116
+ outerBounds(): Record<string, number>;
117
+ /**
118
+ The padding between each key.
119
+ */
120
+ padding(): number;
121
+ padding(_: number): this;
122
+ /**
123
+ The SVG container element as a d3 selector or DOM element.
124
+ */
125
+ select(): D3Selection;
126
+ select(_: any): this;
127
+ /**
128
+ The shape type used for each legend entry.
129
+ */
130
+ shape(): (d: DataPoint, i?: number) => unknown;
131
+ shape(_: ((d: DataPoint, i?: number) => unknown) | unknown): this;
132
+ /**
133
+ Methods that correspond to the key/value pairs for each shape.
134
+ */
135
+ shapeConfig(): Record<string, unknown>;
136
+ shapeConfig(_: Record<string, unknown>): this;
137
+ /**
138
+ Title of the legend.
139
+ */
140
+ title(): string | undefined;
141
+ title(_: string): this;
142
+ /**
143
+ Title configuration of the legend.
144
+ */
145
+ titleConfig(): Record<string, unknown>;
146
+ titleConfig(_: Record<string, unknown>): this;
147
+ /**
148
+ The vertical alignment.
149
+ */
150
+ verticalAlign(): string;
151
+ verticalAlign(_: string): this;
152
+ /**
153
+ Overall width of the legend.
154
+ */
155
+ width(): number;
156
+ width(_: number): this;
157
+ }
@@ -0,0 +1,40 @@
1
+ import type { D3Selection } from "@d3plus/dom";
2
+ interface HideOptions {
3
+ duration?: number;
4
+ callback?: (() => void) | null;
5
+ }
6
+ interface RenderOptions {
7
+ callback?: (() => void) | null;
8
+ container?: string;
9
+ duration?: number;
10
+ html?: string;
11
+ mask?: string | false;
12
+ style?: Record<string, unknown>;
13
+ }
14
+ /**
15
+ Displays a message using plain HTML.
16
+ @private
17
+ */
18
+ export default class Message {
19
+ _isVisible: boolean;
20
+ mask: D3Selection;
21
+ elem: D3Selection;
22
+ /**
23
+ Invoked when creating a new class instance, and sets any default parameters.
24
+ @private
25
+ */
26
+ constructor();
27
+ /**
28
+ Removes the message from the page.
29
+ */
30
+ exit(elem: D3Selection, duration: number): void;
31
+ /**
32
+ Removes the message from the page.
33
+ */
34
+ hide({ duration, callback }?: HideOptions): this;
35
+ /**
36
+ Draws the message given the specified configuration.
37
+ */
38
+ render({ callback, container, duration, html, mask, style, }?: RenderOptions): this;
39
+ }
40
+ export {};
@@ -0,0 +1,278 @@
1
+ import "d3-transition";
2
+ import type { DataPoint } from "@d3plus/data";
3
+ import type { D3Selection } from "@d3plus/dom";
4
+ import { BaseClass } from "../utils/index.js";
5
+ /** Internal shape produced by the data reduce in render(). */
6
+ interface TextBoxDatum {
7
+ aH: string;
8
+ data: DataPoint;
9
+ i: number;
10
+ lines: string[];
11
+ fC: string;
12
+ fStroke: string;
13
+ fSW: number;
14
+ fF: string;
15
+ fO: number;
16
+ fW: number | string;
17
+ id: string;
18
+ tA: string;
19
+ vA: string;
20
+ widths: number[];
21
+ fS: number;
22
+ lH: number;
23
+ w: number;
24
+ h: number;
25
+ r: number;
26
+ x: number;
27
+ y: number;
28
+ }
29
+ /**
30
+ Creates a wrapped text box for each point in an array of data. See [this example](https://d3plus.org/examples/d3plus-text/getting-started/) for help getting started using the TextBox class.
31
+ */
32
+ export default class TextBox extends BaseClass {
33
+ _select: D3Selection;
34
+ _data: DataPoint[];
35
+ _ariaHidden: (d: DataPoint, i?: number) => string;
36
+ _delay: number;
37
+ _duration: number;
38
+ _ellipsis: (text: string, line: number) => string;
39
+ _fontColor: (d: DataPoint, i?: number) => string;
40
+ _fontFamily: (d: DataPoint, i?: number) => string;
41
+ _fontMax: (d: DataPoint, i?: number) => number;
42
+ _fontMin: (d: DataPoint, i?: number) => number;
43
+ _fontOpacity: (d: DataPoint, i?: number) => number;
44
+ _fontResize: (d: DataPoint, i?: number) => boolean;
45
+ _fontSize: (d: DataPoint, i?: number) => number;
46
+ _fontStroke: (d: DataPoint, i?: number) => string;
47
+ _fontStrokeWidth: (d: DataPoint, i?: number) => number;
48
+ _fontWeight: (d: DataPoint, i?: number) => number | string;
49
+ _height: (d: DataPoint, i?: number) => number;
50
+ _html: Record<string, string> | false;
51
+ _id: (d: DataPoint, i: number) => string;
52
+ _lineHeight: (d: DataPoint, i?: number) => number;
53
+ _maxLines: (d: DataPoint, i?: number) => number | null;
54
+ _on: Record<string, (...args: unknown[]) => unknown>;
55
+ _overflow: (d: DataPoint, i?: number) => boolean;
56
+ _padding: (d: DataPoint, i?: number) => number | string;
57
+ _pointerEvents: (d: DataPoint, i?: number) => string;
58
+ _rotate: (d: DataPoint, i?: number) => number;
59
+ _rotateAnchor: (d: TextBoxDatum, i?: number) => [number, number];
60
+ _split: (text: string, i?: number) => string[];
61
+ _text: (d: DataPoint, i?: number) => string | undefined;
62
+ _textAnchor: (d: DataPoint, i?: number) => string;
63
+ _verticalAlign: (d: DataPoint, i?: number) => string;
64
+ _width: (d: DataPoint, i?: number) => number;
65
+ _x: (d: DataPoint, i?: number) => number;
66
+ _y: (d: DataPoint, i?: number) => number;
67
+ /**
68
+ Invoked when creating a new class instance, and sets any default parameters.
69
+ @private
70
+ */
71
+ constructor();
72
+ /**
73
+ Renders the text boxes. If a *callback* is specified, it will be called once the shapes are done drawing.
74
+ @param callback Optional callback invoked after rendering completes.
75
+ */
76
+ render(callback?: (...args: unknown[]) => unknown): this;
77
+ /**
78
+ The aria-hidden attribute.
79
+ */
80
+ ariaHidden(): (d: DataPoint, i?: number) => string;
81
+ ariaHidden(_: string | ((d: DataPoint, i?: number) => string)): this;
82
+ /**
83
+ The data array used to draw text boxes. A text box will be drawn for each object in the array.
84
+ */
85
+ data(): DataPoint[];
86
+ data(_: DataPoint[]): this;
87
+ /**
88
+ The animation delay in milliseconds.
89
+ */
90
+ delay(): number;
91
+ delay(_: number): this;
92
+ /**
93
+ The animation duration in milliseconds.
94
+ */
95
+ duration(): number;
96
+ duration(_: number): this;
97
+ /**
98
+ The function that handles truncated lines. It should return the new value for the line, and is passed 2 arguments: the String of text for the line in question, and the number of the line. By default, an ellipsis is added to the end of any line except if it is the first word that cannot fit (in that case, an empty string is returned).
99
+
100
+ @example <caption>default accessor</caption>
101
+ function(text, line) {
102
+ return line ? text.replace(/\.|,$/g, "") + "..." : "";
103
+ }
104
+ */
105
+ ellipsis(): (text: string, line: number) => string;
106
+ ellipsis(_: ((text: string, line: number) => string) | string): this;
107
+ /**
108
+ The font color as an accessor function or static string. Inferred from the [DOM selection](#textBox.select) by default.
109
+ */
110
+ fontColor(): (d: DataPoint, i?: number) => string;
111
+ fontColor(_: string | ((d: DataPoint, i?: number) => string)): this;
112
+ /**
113
+ Defines the font-family to be used. The value passed can be either a *String* name of a font, a comma-separated list of font-family fallbacks, an *Array* of fallbacks, or a *Function* that returns either a *String* or an *Array*. If supplying multiple fallback fonts, the [fontExists](#fontExists) function will be used to determine the first available font on the client's machine.
114
+ */
115
+ fontFamily(): (d: DataPoint, i?: number) => string;
116
+ fontFamily(_: string | ((d: DataPoint, i?: number) => string)): this;
117
+ /**
118
+ The maximum font size in pixels, used when [dynamically resizing fonts](#textBox.fontResize).
119
+ */
120
+ fontMax(): (d: DataPoint, i?: number) => number;
121
+ fontMax(_: number | ((d: DataPoint, i?: number) => number)): this;
122
+ /**
123
+ The minimum font size in pixels, used when [dynamically resizing fonts](#textBox.fontResize).
124
+ */
125
+ fontMin(): (d: DataPoint, i?: number) => number;
126
+ fontMin(_: number | ((d: DataPoint, i?: number) => number)): this;
127
+ /**
128
+ The font opacity as an accessor function or static number between 0 and 1.
129
+ */
130
+ fontOpacity(): (d: DataPoint, i?: number) => number;
131
+ fontOpacity(_: number | ((d: DataPoint, i?: number) => number)): this;
132
+ /**
133
+ Toggles font resizing, which can either be defined as a static boolean for all data points, or an accessor function that returns a boolean. See [this example](http://d3plus.org/examples/d3plus-text/resizing-text/) for a side-by-side comparison.
134
+ */
135
+ fontResize(): (d: DataPoint, i?: number) => boolean;
136
+ fontResize(_: boolean | ((d: DataPoint, i?: number) => boolean)): this;
137
+ /**
138
+ The font size in pixels. Inferred from the [DOM selection](#textBox.select) by default.
139
+ */
140
+ fontSize(): (d: DataPoint, i?: number) => number;
141
+ fontSize(_: number | ((d: DataPoint, i?: number) => number)): this;
142
+ /**
143
+ The font stroke color for the rendered text.
144
+ */
145
+ fontStroke(): (d: DataPoint, i?: number) => string;
146
+ fontStroke(_: string | ((d: DataPoint, i?: number) => string)): this;
147
+ /**
148
+ The font stroke width for the rendered text.
149
+ */
150
+ fontStrokeWidth(): (d: DataPoint, i?: number) => number;
151
+ fontStrokeWidth(_: number | ((d: DataPoint, i?: number) => number)): this;
152
+ /**
153
+ The font weight. Inferred from the [DOM selection](#textBox.select) by default.
154
+ */
155
+ fontWeight(): (d: DataPoint, i?: number) => number | string;
156
+ fontWeight(_: number | string | ((d: DataPoint, i?: number) => number | string)): this;
157
+ /**
158
+ The height for each text box.
159
+
160
+ @example <caption>default accessor</caption>
161
+ function(d) {
162
+ return d.height || 200;
163
+ }
164
+ */
165
+ height(): (d: DataPoint, i?: number) => number;
166
+ height(_: number | ((d: DataPoint, i?: number) => number)): this;
167
+ /**
168
+ Configures the ability to render simple HTML tags. Defaults to supporting `<b>`, `<strong>`, `<i>`, and `<em>`, set to false to disable or provide a mapping of tags to svg styles
169
+ */
170
+ html(): Record<string, string> | false;
171
+ html(_: Record<string, string> | boolean): this;
172
+ /**
173
+ The unique id for each text box.
174
+
175
+ @example <caption>default accessor</caption>
176
+ function(d, i) {
177
+ return d.id || i + "";
178
+ }
179
+ */
180
+ id(): (d: DataPoint, i: number) => string;
181
+ id(_: string | ((d: DataPoint, i: number) => string)): this;
182
+ /**
183
+ The line height, which is 1.2 times the [font size](#textBox.fontSize) by default.
184
+ */
185
+ lineHeight(): (d: DataPoint, i?: number) => number;
186
+ lineHeight(_: ((d: DataPoint, i?: number) => number) | number): this;
187
+ /**
188
+ Restricts the maximum number of lines to wrap onto, which is null (unlimited) by default.
189
+ */
190
+ maxLines(): (d: DataPoint, i?: number) => number | null;
191
+ maxLines(_: number | null | ((d: DataPoint, i?: number) => number | null)): this;
192
+ /**
193
+ Whether text is allowed to overflow its bounding box.
194
+ */
195
+ overflow(): (d: DataPoint, i?: number) => boolean;
196
+ overflow(_: boolean | ((d: DataPoint, i?: number) => boolean)): this;
197
+ /**
198
+ The padding as a CSS shorthand string or number. Defaults to 0.
199
+ */
200
+ padding(): (d: DataPoint, i?: number) => number | string;
201
+ padding(_: number | string | ((d: DataPoint, i?: number) => number | string)): this;
202
+ /**
203
+ The pointer-events CSS property for each text box.
204
+ */
205
+ pointerEvents(): (d: DataPoint, i?: number) => string;
206
+ pointerEvents(_: string | ((d: DataPoint, i?: number) => string)): this;
207
+ /**
208
+ The rotation angle in degrees for each text box.
209
+ */
210
+ rotate(): (d: DataPoint, i?: number) => number;
211
+ rotate(_: number | ((d: DataPoint, i?: number) => number)): this;
212
+ /**
213
+ The anchor point around which to rotate the text box.
214
+ */
215
+ rotateAnchor(): (d: DataPoint, i?: number) => [number, number];
216
+ rotateAnchor(_: ((d: DataPoint, i?: number) => [number, number]) | [number, number]): this;
217
+ /**
218
+ The SVG container element as a d3 selector or DOM element. If not specified, an SVG element will be added to the page.
219
+ */
220
+ select(): D3Selection;
221
+ select(_: string | HTMLElement): this;
222
+ /**
223
+ The word split function, which when passed a string is expected to return that string split into an array of words.
224
+ */
225
+ split(): (text: string, i?: number) => string[];
226
+ split(_: (text: string, i?: number) => string[]): this;
227
+ /**
228
+ The text content for each box.
229
+
230
+ @example <caption>default accessor</caption>
231
+ function(d) {
232
+ return d.text;
233
+ }
234
+ */
235
+ text(): (d: DataPoint, i?: number) => string | undefined;
236
+ text(_: string | ((d: DataPoint, i?: number) => string | undefined)): this;
237
+ /**
238
+ The horizontal text anchor, analagous to the SVG [text-anchor](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor) property.
239
+ */
240
+ textAnchor(): (d: DataPoint, i?: number) => string;
241
+ textAnchor(_: string | ((d: DataPoint, i?: number) => string)): this;
242
+ /**
243
+ The vertical alignment. Accepts `"top"`, `"middle"`, and `"bottom"`.
244
+ */
245
+ verticalAlign(): (d: DataPoint, i?: number) => string;
246
+ verticalAlign(_: string | ((d: DataPoint, i?: number) => string)): this;
247
+ /**
248
+ The width for each text box.
249
+
250
+ @example <caption>default accessor</caption>
251
+ function(d) {
252
+ return d.width || 200;
253
+ }
254
+ */
255
+ width(): (d: DataPoint, i?: number) => number;
256
+ width(_: number | ((d: DataPoint, i?: number) => number)): this;
257
+ /**
258
+ The x position for each text box. The number given should correspond to the left side of the textBox.
259
+
260
+ @example <caption>default accessor</caption>
261
+ function(d) {
262
+ return d.x || 0;
263
+ }
264
+ */
265
+ x(): (d: DataPoint, i?: number) => number;
266
+ x(_: number | ((d: DataPoint, i?: number) => number)): this;
267
+ /**
268
+ The y position for each text box. The number given should correspond to the top side of the textBox.
269
+
270
+ @example <caption>default accessor</caption>
271
+ function(d) {
272
+ return d.y || 0;
273
+ }
274
+ */
275
+ y(): (d: DataPoint, i?: number) => number;
276
+ y(_: number | ((d: DataPoint, i?: number) => number)): this;
277
+ }
278
+ export {};
@@ -0,0 +1,157 @@
1
+ import { Axis, TextBox } from "../components/index.js";
2
+ /**
3
+ Creates an interactive timeline brush component for selecting time periods within a visualization.
4
+ */
5
+ export default class Timeline extends Axis {
6
+ _brushing: boolean;
7
+ _brushFilter: (event: unknown) => boolean;
8
+ _brushMin: () => number;
9
+ _buttonAlign: string;
10
+ _buttonBehavior: string;
11
+ _buttonBehaviorCurrent: string;
12
+ _buttonPadding: number;
13
+ _buttonHeight: number;
14
+ _handleConfig: Record<string, unknown>;
15
+ _handleSize: number;
16
+ _hiddenHandles: boolean;
17
+ _on: Record<string, (...args: unknown[]) => unknown>;
18
+ _playButton: boolean;
19
+ _playButtonClass: TextBox;
20
+ _playButtonConfig: Record<string, unknown>;
21
+ _playButtonInterval: number;
22
+ _playTimer: ReturnType<typeof setInterval> | false;
23
+ _selection: unknown;
24
+ _selectionConfig: Record<string, unknown>;
25
+ _snapping: boolean;
26
+ _brush: any;
27
+ _brushGroup: any;
28
+ _paddingLeft: number;
29
+ _ticksWidth: number;
30
+ /**
31
+ Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
32
+ @private
33
+ */
34
+ constructor();
35
+ /**
36
+ Triggered on brush "brush".
37
+ @private
38
+ */
39
+ _brushBrush(event: Record<string, unknown>): void;
40
+ /**
41
+ Triggered on brush "end".
42
+ @private
43
+ */
44
+ _brushEnd(event: Record<string, unknown>): void;
45
+ /**
46
+ Triggered on brush "start".
47
+ @private
48
+ */
49
+ _brushStart(event: Record<string, unknown>): void;
50
+ /**
51
+ Overrides the default brush styles.
52
+ @private
53
+ */
54
+ _brushStyle(): void;
55
+ /**
56
+ Updates domain of the timeline used in brush functions.
57
+ @private
58
+ */
59
+ _updateDomain(event: Record<string, unknown>): unknown[];
60
+ /**
61
+ Updates limits of the brush.
62
+ @private
63
+ */
64
+ _updateBrushLimit(domain: unknown[]): unknown[];
65
+ /**
66
+ Draws the timeline.
67
+ @param callback Optional callback invoked after rendering completes.
68
+ */
69
+ render(callback?: (...args: unknown[]) => unknown): this;
70
+ /**
71
+ Button padding.
72
+ */
73
+ buttonPadding(): number;
74
+ buttonPadding(_: number): this;
75
+ /**
76
+ Toggles the brushing value.
77
+ */
78
+ brushing(): boolean;
79
+ brushing(_: boolean): this;
80
+ /**
81
+ Brush event filter.
82
+
83
+ @example
84
+ function() {
85
+ return !event.button && event.detail < 2;
86
+ }
87
+ */
88
+ brushFilter(): (event: unknown) => boolean;
89
+ brushFilter(_: (event: unknown) => boolean): this;
90
+ /**
91
+ The minimum number of ticks that can be highlighted when using "ticks" buttonBehavior. Helpful when using x/y plots where you don't want the user to select less than 2 time periods.
92
+ */
93
+ brushMin(): () => number;
94
+ brushMin(_: (() => number) | number): this;
95
+ /**
96
+ Toggles the horizontal alignment of the button timeline. Accepted values are `"start"`, `"middle"` and `"end"`.
97
+ */
98
+ buttonAlign(): string;
99
+ buttonAlign(_: string): this;
100
+ /**
101
+ Toggles the style of the timeline. Accepted values are `"auto"`, `"buttons"` and `"ticks"`.
102
+ */
103
+ buttonBehavior(): string;
104
+ buttonBehavior(_: string): this;
105
+ /**
106
+ Button height.
107
+ */
108
+ buttonHeight(): number;
109
+ buttonHeight(_: number): this;
110
+ /**
111
+ Handle style.
112
+ */
113
+ handleConfig(): Record<string, unknown>;
114
+ handleConfig(_: Record<string, unknown>): this;
115
+ /**
116
+ Handle size.
117
+ */
118
+ handleSize(): number;
119
+ handleSize(_: number): this;
120
+ /**
121
+ Event listener for the specified brush event *typename*. Mirrors the core [d3-brush](https://github.com/d3/d3-brush#brush_on) behavior.
122
+ */
123
+ on(): Record<string, (...args: unknown[]) => unknown>;
124
+ on(_: string): ((...args: unknown[]) => unknown) | undefined;
125
+ on(_: string, f: (...args: unknown[]) => unknown): this;
126
+ on(_: Record<string, (...args: unknown[]) => unknown>): this;
127
+ /**
128
+ Determines the visibility of the play button to the left the of timeline, which will cycle through the available periods at a rate defined by the playButtonInterval method.
129
+ */
130
+ playButton(): boolean;
131
+ playButton(_: boolean): this;
132
+ /**
133
+ The config Object for the Rect class used to create the playButton.
134
+ */
135
+ playButtonConfig(): Record<string, unknown>;
136
+ playButtonConfig(_: Record<string, unknown>): this;
137
+ /**
138
+ The value, in milliseconds, to use when cycling through the available time periods when the user clicks the playButton.
139
+ */
140
+ playButtonInterval(): number;
141
+ playButtonInterval(_: number): this;
142
+ /**
143
+ Selection style.
144
+ */
145
+ selectionConfig(): Record<string, unknown>;
146
+ selectionConfig(_: Record<string, unknown>): this;
147
+ /**
148
+ Selection. Defaults to the most recent year in the timeline.
149
+ */
150
+ selection(): unknown;
151
+ selection(_: unknown): this;
152
+ /**
153
+ Toggles the snapping value.
154
+ */
155
+ snapping(): boolean;
156
+ snapping(_: boolean): this;
157
+ }