@oliasoft-open-source/charts-library 8.0.5 → 9.0.0-beta-1
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.
- package/dist/index.d.ts +15 -2249
- package/dist/index.js +927 -898
- package/dist/src/components/bar-chart/bar-chart-const.d.ts +2 -0
- package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +3 -0
- package/dist/src/components/bar-chart/bar-chart.d.ts +43 -0
- package/dist/src/components/bar-chart/bar-chart.interface.d.ts +252 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-data-labels.d.ts +10 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-scales.d.ts +4 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-tooltips.d.ts +6 -0
- package/dist/src/components/bar-chart/utils/use-bar-chart-config.d.ts +13 -0
- package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +54 -0
- package/dist/src/components/common/common.interface.d.ts +510 -0
- package/dist/src/components/common/controls-portal.d.ts +7 -0
- package/dist/src/components/common/enums.d.ts +104 -0
- package/dist/src/components/common/helpers/add-transparency/add-transparency.d.ts +1 -0
- package/dist/src/components/common/helpers/callout-helpers/callout-helpers.d.ts +25 -0
- package/dist/src/components/common/helpers/chart-border-plugin.d.ts +16 -0
- package/dist/src/components/common/helpers/chart-consts.d.ts +40 -0
- package/dist/src/components/common/helpers/chart-utils.d.ts +86 -0
- package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -0
- package/dist/src/components/common/helpers/download-png.d.ts +3 -0
- package/dist/src/components/common/helpers/get-cartesian-scale-options.d.ts +28 -0
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +139 -0
- package/dist/src/components/common/helpers/get-chart-from-ctx.d.ts +1 -0
- package/dist/src/components/common/helpers/get-draggableData.d.ts +18 -0
- package/dist/src/components/common/helpers/get-grouped-color-scheme/get-grouped-color-scheme.d.ts +12 -0
- package/dist/src/components/common/helpers/input-normalizers.d.ts +15 -0
- package/dist/src/components/common/helpers/range/estimate-data-series-have-close-values.d.ts +8 -0
- package/dist/src/components/common/helpers/range/range.d.ts +33 -0
- package/dist/src/components/common/helpers/to-annotation.d.ts +4 -0
- package/dist/src/components/common/hooks/use-generated-labels.d.ts +4 -0
- package/dist/src/components/common/hooks/use-legend-state.d.ts +28 -0
- package/dist/src/components/common/hooks/use-legend.d.ts +4 -0
- package/dist/src/components/common/hooks/use-update-annotations.d.ts +4 -0
- package/dist/src/components/common/legend-component/legend-dropzone.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-interface.d.ts +50 -0
- package/dist/src/components/common/legend-component/legend-item/LegendItemLine.d.ts +5 -0
- package/dist/src/components/common/legend-component/legend-item/legend-item.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-panel.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-position-storage.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend.d.ts +3 -0
- package/dist/src/components/common/legend-component/state/legend-action-types.d.ts +3 -0
- package/dist/src/components/common/legend-component/state/legend-context.d.ts +14 -0
- package/dist/src/components/common/legend-component/state/legend-state-reducer.d.ts +30 -0
- package/dist/src/components/common/legend-component/utils/create-style-object.d.ts +27 -0
- package/dist/src/components/common/legend-component/utils/get-generated-labels.d.ts +3 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-dragger-plugin.d.ts +15 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-position-storage.d.ts +7 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +23 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/event-helpers.d.ts +6 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/helpers.d.ts +53 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/point-annotation-label.d.ts +5 -0
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts +9 -0
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +18 -0
- package/dist/src/components/common/plugins/gradient-background-plugin/enums.d.ts +11 -0
- package/dist/src/components/common/plugins/gradient-background-plugin/gradient-background-plugin.d.ts +2 -0
- package/dist/src/components/line-chart/constants/default-translations.d.ts +25 -0
- package/dist/src/components/line-chart/constants/line-chart-consts.d.ts +13 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +57 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-options.d.ts +6 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-validation.d.ts +8 -0
- package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +19 -0
- package/dist/src/components/line-chart/controls/controls.d.ts +4 -0
- package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +14 -0
- package/dist/src/components/line-chart/controls/drag-options.d.ts +23 -0
- package/dist/src/components/line-chart/controls/line-options.d.ts +19 -0
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +32 -0
- package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +20 -0
- package/dist/src/components/line-chart/hooks/use-chart-plugins.d.ts +7 -0
- package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +12 -0
- package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +12 -0
- package/dist/src/components/line-chart/initialize/config.d.ts +12 -0
- package/dist/src/components/line-chart/initialize/initialize-line-chart.d.ts +17 -0
- package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +3 -0
- package/dist/src/components/line-chart/line-chart.d.ts +42 -0
- package/dist/src/components/line-chart/line-chart.interface.d.ts +458 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/helpers.d.ts +42 -0
- package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +17 -0
- package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +8 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/draw.d.ts +39 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/line-markers-plugin.d.ts +10 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/types.d.ts +204 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/utils.d.ts +40 -0
- package/dist/src/components/line-chart/plugins/plugin-constants.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +9 -0
- package/dist/src/components/line-chart/state/action-types.d.ts +12 -0
- package/dist/src/components/line-chart/state/helpers.d.ts +13 -0
- package/dist/src/components/line-chart/state/initial-state.d.ts +11 -0
- package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +2 -0
- package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +15 -0
- package/dist/src/components/line-chart/state/state.interfaces.d.ts +26 -0
- package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +2 -0
- package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +18 -0
- package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.d.ts +12 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/datalabels-alignment.interface.d.ts +20 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts +8 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +11 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +6 -0
- package/dist/src/components/line-chart/utils/enums.d.ts +4 -0
- package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +8 -0
- package/dist/src/components/line-chart/utils/get-annotations-data.d.ts +8 -0
- package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +5 -0
- package/dist/src/components/line-chart/utils/get-axis-range-by-type.d.ts +9 -0
- package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +16 -0
- package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +5 -0
- package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +31 -0
- package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +24 -0
- package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +8 -0
- package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +50 -0
- package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +3 -0
- package/dist/src/components/pie-chart/pie-chart.d.ts +38 -0
- package/dist/src/components/pie-chart/pie-chart.interface.d.ts +150 -0
- package/dist/src/components/pie-chart/use-pie-chart-config.d.ts +42 -0
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +69 -0
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +73 -0
- package/dist/src/components/scatter-chart/scatter-chart-get-default-props.d.ts +4 -0
- package/dist/src/components/scatter-chart/scatter-chart.d.ts +41 -0
- package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +193 -0
- package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +5 -0
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +21 -0
- package/package.json +34 -34
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/** Left/right attachment side for line markers. */
|
|
2
|
+
export declare enum LineMarkerSide {
|
|
3
|
+
Left = "left",
|
|
4
|
+
Right = "right"
|
|
5
|
+
}
|
|
6
|
+
/** Orientation of a line marker. */
|
|
7
|
+
export declare enum LineMarkerDirection {
|
|
8
|
+
Vertical = "vertical",
|
|
9
|
+
Horizontal = "horizontal"
|
|
10
|
+
}
|
|
11
|
+
/** Label placement relative to a line marker. */
|
|
12
|
+
export declare enum LineMarkerLabelPosition {
|
|
13
|
+
Left = "left",
|
|
14
|
+
Right = "right",
|
|
15
|
+
Top = "top",
|
|
16
|
+
Bottom = "bottom",
|
|
17
|
+
OnLine = "onLine"
|
|
18
|
+
}
|
|
19
|
+
/** Horizontal alignment of marker label text. */
|
|
20
|
+
export declare enum LineMarkerTextAlign {
|
|
21
|
+
Left = "left",
|
|
22
|
+
Right = "right",
|
|
23
|
+
Center = "center"
|
|
24
|
+
}
|
|
25
|
+
/** Attachment side accepted by marker options. */
|
|
26
|
+
export type TStickSide = LineMarkerSide;
|
|
27
|
+
/** Orientation accepted by marker items. */
|
|
28
|
+
export type TLineMarkerDirection = LineMarkerDirection;
|
|
29
|
+
/** Placement accepted by marker tick labels. */
|
|
30
|
+
export type TLineMarkerLabelPosition = LineMarkerLabelPosition;
|
|
31
|
+
/** Text alignment accepted by marker label helpers. */
|
|
32
|
+
export type TLineMarkerTextAlign = LineMarkerTextAlign;
|
|
33
|
+
/** Tick styling and optional text at a marker endpoint. */
|
|
34
|
+
export type TLineMarkerTick = {
|
|
35
|
+
/** Whether this feature is active. */
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
/** Display text associated with this element. */
|
|
38
|
+
label?: string | string[];
|
|
39
|
+
/** Canvas/CSS colour used by this element. */
|
|
40
|
+
color?: string;
|
|
41
|
+
/** Canvas font specification used for the text. */
|
|
42
|
+
font?: string;
|
|
43
|
+
/** Pixel offset between the label and its associated geometry. */
|
|
44
|
+
labelOffsetPx?: number;
|
|
45
|
+
/** Label placement relative to the marker or tick. */
|
|
46
|
+
labelPosition?: TLineMarkerLabelPosition;
|
|
47
|
+
/** Side on which the marker tick or branch is drawn. */
|
|
48
|
+
side?: TStickSide;
|
|
49
|
+
/** Reverses the relevant scale or marker direction. */
|
|
50
|
+
reverse?: boolean;
|
|
51
|
+
/** Tick size in pixels. */
|
|
52
|
+
sizePx?: number;
|
|
53
|
+
};
|
|
54
|
+
/** Additional tick or branch attached to a line marker. */
|
|
55
|
+
export type TMarkerExtraItem = {
|
|
56
|
+
/** Identifier used to associate this configuration with its rendered element. */
|
|
57
|
+
id?: string;
|
|
58
|
+
/** Whether this element is visible. */
|
|
59
|
+
display?: boolean;
|
|
60
|
+
/** Vertical Chart.js scale ID used to resolve annotation coordinates. */
|
|
61
|
+
yScaleID?: string;
|
|
62
|
+
/** Y coordinate in scale units. */
|
|
63
|
+
yValue?: number;
|
|
64
|
+
/** Numeric value or axis coordinate represented by this item. */
|
|
65
|
+
value?: number;
|
|
66
|
+
/** Explicit marker length in pixels instead of a span derived from axis values. */
|
|
67
|
+
lengthPx?: number;
|
|
68
|
+
/** Side on which the marker tick or branch is drawn. */
|
|
69
|
+
side?: TStickSide;
|
|
70
|
+
/** Reverses the relevant scale or marker direction. */
|
|
71
|
+
reverse?: boolean;
|
|
72
|
+
/** Canvas/CSS colour used by this element. */
|
|
73
|
+
color?: string;
|
|
74
|
+
/** Opacity multiplier between 0 (transparent) and 1 (opaque). */
|
|
75
|
+
opacity?: number;
|
|
76
|
+
/** Stroke width in canvas pixels. */
|
|
77
|
+
lineWidth?: number;
|
|
78
|
+
/** Alternating marker dash and gap lengths in pixels. */
|
|
79
|
+
lineDash?: number[];
|
|
80
|
+
/** Tick and label settings for this extra marker branch. */
|
|
81
|
+
tick?: TLineMarkerTick;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* One marker with optional endpoints, ticks and labels.
|
|
85
|
+
* Item settings override the shared {@link TLineMarkersOptions} values.
|
|
86
|
+
*/
|
|
87
|
+
export type TLineMarkerItem = {
|
|
88
|
+
/** Identifier used to associate this configuration with its rendered element. */
|
|
89
|
+
id?: string;
|
|
90
|
+
/** Chart orientation. Support and interpretation depend on the chart component. */
|
|
91
|
+
direction?: TLineMarkerDirection;
|
|
92
|
+
/** Horizontal Chart.js scale ID used to resolve annotation coordinates. */
|
|
93
|
+
xScaleID?: string;
|
|
94
|
+
/** Vertical Chart.js scale ID used to resolve annotation coordinates. */
|
|
95
|
+
yScaleID?: string;
|
|
96
|
+
/** X coordinate in scale units. */
|
|
97
|
+
xValue?: number;
|
|
98
|
+
/** Y coordinate in scale units. */
|
|
99
|
+
yValue?: number;
|
|
100
|
+
/** Vertical start coordinate in scale units. */
|
|
101
|
+
yStartValue?: number;
|
|
102
|
+
/** Vertical end coordinate in scale units. */
|
|
103
|
+
yEndValue?: number;
|
|
104
|
+
/** Horizontal start coordinate in scale units. */
|
|
105
|
+
xStartValue?: number;
|
|
106
|
+
/** Horizontal end coordinate in scale units. */
|
|
107
|
+
xEndValue?: number;
|
|
108
|
+
/** Explicit marker length in pixels instead of a span derived from axis values. */
|
|
109
|
+
lengthPx?: number;
|
|
110
|
+
/** Numeric value or axis coordinate represented by this item. */
|
|
111
|
+
value?: number;
|
|
112
|
+
/** Display text associated with this element. */
|
|
113
|
+
label?: string | string[];
|
|
114
|
+
/** Canvas font specification used for the text. */
|
|
115
|
+
font?: string;
|
|
116
|
+
/** Pixel offset between the label and its associated geometry. */
|
|
117
|
+
labelOffsetPx?: number;
|
|
118
|
+
/** Attaches marker geometry to a chart edge. */
|
|
119
|
+
stickToEdge?: boolean;
|
|
120
|
+
/** Aligns marker geometry to the shared group anchor. */
|
|
121
|
+
stickToGroup?: boolean;
|
|
122
|
+
/** Chart edge used for attached markers. */
|
|
123
|
+
stickSide?: TStickSide;
|
|
124
|
+
/** Additional pixel offset from the shared marker group anchor. */
|
|
125
|
+
groupOffsetPx?: number;
|
|
126
|
+
/** Reverses the relevant scale or marker direction. */
|
|
127
|
+
reverse?: boolean;
|
|
128
|
+
/** Canvas/CSS colour used by this element. */
|
|
129
|
+
color?: string;
|
|
130
|
+
/** Opacity multiplier between 0 (transparent) and 1 (opaque). */
|
|
131
|
+
opacity?: number;
|
|
132
|
+
/** Stroke width in canvas pixels. */
|
|
133
|
+
lineWidth?: number;
|
|
134
|
+
/** Alternating marker dash and gap lengths in pixels. */
|
|
135
|
+
lineDash?: number[];
|
|
136
|
+
/** Tick and label configuration for the marker start. */
|
|
137
|
+
startTick?: TLineMarkerTick;
|
|
138
|
+
/** Tick and label configuration for the marker end. */
|
|
139
|
+
endTick?: TLineMarkerTick;
|
|
140
|
+
/** Additional ticks or branches attached to this marker. */
|
|
141
|
+
extras?: TMarkerExtraItem[];
|
|
142
|
+
/** Whether this element is visible. */
|
|
143
|
+
display?: boolean;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Shared marker defaults and marker items.
|
|
147
|
+
* Configure through `options.annotations.lineMarkersAnnotation`.
|
|
148
|
+
*/
|
|
149
|
+
export type TLineMarkersOptions = {
|
|
150
|
+
/** Whether this feature is active. */
|
|
151
|
+
enabled?: boolean;
|
|
152
|
+
/** Spacing between grouped marker items in pixels. */
|
|
153
|
+
itemGapPx?: number;
|
|
154
|
+
/** Gap between edge-attached markers and the chart boundary, in pixels. */
|
|
155
|
+
edgePaddingPx?: number;
|
|
156
|
+
/** Default length of horizontal marker lines in pixels. */
|
|
157
|
+
horizontalLineLengthPx?: number;
|
|
158
|
+
/** Default orientation for marker items. */
|
|
159
|
+
lineDirection?: TLineMarkerDirection;
|
|
160
|
+
/** Vertical clearance used when resolving marker label overlaps, in pixels. */
|
|
161
|
+
labelCollisionPx?: number;
|
|
162
|
+
/** Horizontal distance used to cluster potentially overlapping marker labels, in pixels. */
|
|
163
|
+
labelCollisionClusterXPx?: number;
|
|
164
|
+
/** Adjusts marker label placement to reduce overlaps. */
|
|
165
|
+
enableLabelCollisionResolver?: boolean;
|
|
166
|
+
/** Attaches marker geometry to a chart edge. */
|
|
167
|
+
stickToEdge?: boolean;
|
|
168
|
+
/** Aligns marker geometry to the shared group anchor. */
|
|
169
|
+
stickToGroup?: boolean;
|
|
170
|
+
/** Chart edge used for attached markers. */
|
|
171
|
+
stickSide?: TStickSide;
|
|
172
|
+
/** Reverses the relevant scale or marker direction. */
|
|
173
|
+
reverse?: boolean;
|
|
174
|
+
/** X coordinate in scale units. */
|
|
175
|
+
xValue?: number;
|
|
176
|
+
/** Y coordinate in scale units. */
|
|
177
|
+
yValue?: number;
|
|
178
|
+
/** Vertical end coordinate in scale units. */
|
|
179
|
+
yEndValue?: number;
|
|
180
|
+
/** Horizontal start coordinate in scale units. */
|
|
181
|
+
xStartValue?: number;
|
|
182
|
+
/** Horizontal end coordinate in scale units. */
|
|
183
|
+
xEndValue?: number;
|
|
184
|
+
/** Explicit marker length in pixels instead of a span derived from axis values. */
|
|
185
|
+
lengthPx?: number;
|
|
186
|
+
/** Vertical start coordinate in scale units. */
|
|
187
|
+
yStartValue?: number;
|
|
188
|
+
/** Canvas/CSS colour used by this element. */
|
|
189
|
+
color?: string;
|
|
190
|
+
/** Opacity multiplier between 0 (transparent) and 1 (opaque). */
|
|
191
|
+
opacity?: number;
|
|
192
|
+
/** Stroke width in canvas pixels. */
|
|
193
|
+
lineWidth?: number;
|
|
194
|
+
/** Alternating marker dash and gap lengths in pixels. */
|
|
195
|
+
lineDash?: number[];
|
|
196
|
+
/** Tick and label configuration for the marker start. */
|
|
197
|
+
startTick?: TLineMarkerTick;
|
|
198
|
+
/** Tick and label configuration for the marker end. */
|
|
199
|
+
endTick?: TLineMarkerTick;
|
|
200
|
+
/** Marker definitions; item settings override the shared marker settings. */
|
|
201
|
+
items?: TLineMarkerItem[];
|
|
202
|
+
};
|
|
203
|
+
/** Annotation configuration alias for the line-marker plugin. */
|
|
204
|
+
export type ILineMarkersAnnotation = TLineMarkersOptions;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Chart, Scale } from 'chart.js';
|
|
2
|
+
import { type TStickSide } from './types.js';
|
|
3
|
+
export declare const isFiniteNumber: (v: unknown) => v is number;
|
|
4
|
+
export declare const asArray: <T>(v: unknown) => T[];
|
|
5
|
+
export declare const asObject: <T extends object>(v: unknown) => T | undefined;
|
|
6
|
+
export declare const getFirstScaleByAxis: (chart: Chart, axis: 'x' | 'y') => Scale | undefined;
|
|
7
|
+
export declare const resolveScale: (chart: Chart, scaleID: string | undefined, axis: 'x' | 'y') => Scale | undefined;
|
|
8
|
+
export declare const getPixelForValueSafe: (scale: Scale | undefined, value: unknown) => number | undefined;
|
|
9
|
+
export declare const clamp: (v: number, min: number, max: number) => number;
|
|
10
|
+
export declare const crispLinePx: (v: number) => number;
|
|
11
|
+
export type TChartArea = {
|
|
12
|
+
top: number;
|
|
13
|
+
bottom: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const computeYRange: ({ chartArea, yStartPx, yEndPx, }: {
|
|
16
|
+
chartArea: TChartArea;
|
|
17
|
+
yStartPx?: number;
|
|
18
|
+
yEndPx?: number;
|
|
19
|
+
}) => {
|
|
20
|
+
y1: number;
|
|
21
|
+
y2: number;
|
|
22
|
+
};
|
|
23
|
+
export declare const toLines: (label?: string | string[]) => string[];
|
|
24
|
+
export declare const lineHeightPx: (font: string) => number;
|
|
25
|
+
export type TLabelCollisionItem = {
|
|
26
|
+
id: string;
|
|
27
|
+
side: TStickSide;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
type TResolveLabelCollisionArgs = {
|
|
33
|
+
labels: TLabelCollisionItem[];
|
|
34
|
+
chartTop: number;
|
|
35
|
+
chartBottom: number;
|
|
36
|
+
clusterXPx: number;
|
|
37
|
+
gapPx: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const resolveLabelCollisions: ({ labels, chartTop, chartBottom, clusterXPx, gapPx, }: TResolveLabelCollisionArgs) => Record<string, number>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const TOGGLE_ZOOM = "TOGGLE_ZOOM";
|
|
2
|
+
export declare const TOGGLE_PAN = "TOGGLE_PAN";
|
|
3
|
+
export declare const TOGGLE_POINTS = "TOGGLE_POINTS";
|
|
4
|
+
export declare const TOGGLE_LINE = "TOGGLE_LINE";
|
|
5
|
+
export declare const TOGGLE_LEGEND = "TOGGLE_LEGEND";
|
|
6
|
+
export declare const TOGGLE_TABLE = "TOGGLE_TABLE";
|
|
7
|
+
export declare const RESET_AXES_RANGES = "RESET_AXES_RANGES";
|
|
8
|
+
export declare const UPDATE_AXES_RANGES = "UPDATE_AXES_RANGES";
|
|
9
|
+
export declare const TOGGLE_DRAG_POINTS = "TOGGLE_DRAG_POINTS";
|
|
10
|
+
export declare const TOGGLE_DRAG_ANNOTATION = "TOGGLE_DRAG_ANNOTATION";
|
|
11
|
+
export declare const DISABLE_DRAG_OPTIONS = "DISABLE_DRAG_OPTIONS";
|
|
12
|
+
export declare const UPDATE_EDITED = "UPDATE_EDITED";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { IState } from './state.interfaces.js';
|
|
3
|
+
import { TChart } from '../../common/common.interface.js';
|
|
4
|
+
export interface IGetInitAxes {
|
|
5
|
+
chartRef: RefObject<TChart | null>;
|
|
6
|
+
state: IState;
|
|
7
|
+
}
|
|
8
|
+
export declare const getInitAxes: ({ chartRef, state }: IGetInitAxes) => {
|
|
9
|
+
id: string;
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
unit: string | import("../line-chart.interface").IUnitOptions | undefined;
|
|
13
|
+
}[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IState } from './state.interfaces';
|
|
2
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
3
|
+
interface inputInitState {
|
|
4
|
+
options: ILineChartOptions;
|
|
5
|
+
persistenceId?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
Initial chart state for the line chart.
|
|
9
|
+
*/
|
|
10
|
+
declare const initialState: ({ options, persistenceId }: inputInitState) => IState;
|
|
11
|
+
export default initialState;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IState } from './state.interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the chart state from local storage.
|
|
4
|
+
*
|
|
5
|
+
* @param {string|''} persistenceId - The chart persistenceId.
|
|
6
|
+
* @returns {object|null} The chart state object or null if not found.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getChartStateFromStorage: (persistenceId?: string) => any;
|
|
9
|
+
/**
|
|
10
|
+
* Stores the chart state in local storage.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} state - The chart state object to store.
|
|
13
|
+
* @param {string|''} persistenceId - The chart persistenceId.
|
|
14
|
+
*/
|
|
15
|
+
export declare const storeChartStateInStorage: (state: IState, persistenceId?: string) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IUnitOptions } from '../line-chart.interface';
|
|
2
|
+
export interface IAxisState {
|
|
3
|
+
id?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
min?: number | string;
|
|
6
|
+
max?: number | string;
|
|
7
|
+
unit?: IUnitOptions | string;
|
|
8
|
+
axisType?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IState {
|
|
11
|
+
zoomEnabled: boolean;
|
|
12
|
+
panEnabled: boolean;
|
|
13
|
+
pointsEnabled: boolean;
|
|
14
|
+
lineEnabled: boolean;
|
|
15
|
+
legendEnabled: boolean;
|
|
16
|
+
axes: IAxisState[];
|
|
17
|
+
showAnnotationLineIndex?: number[];
|
|
18
|
+
showTable: boolean;
|
|
19
|
+
enableDragPoints: boolean;
|
|
20
|
+
enableDragAnnotation: boolean;
|
|
21
|
+
edited: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface IAction<T = string, P = any> {
|
|
24
|
+
type: T;
|
|
25
|
+
payload?: P;
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ILineChartOptions, TGeneratedLineChartDatasets } from '../../line-chart.interface';
|
|
2
|
+
import { IState } from '../../state/state.interfaces';
|
|
3
|
+
interface IScaleValue {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
interface IScales {
|
|
9
|
+
[key: string]: IScaleValue;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Auto scales axis ranges (mix, max) if no explicit range is set
|
|
13
|
+
* - overrides some edge cases not handled well by default chart.js
|
|
14
|
+
* - supports optional padding when `autoAxisPadding` is set
|
|
15
|
+
* - otherwise does not set min/max (falls back to chart.js default)
|
|
16
|
+
*/
|
|
17
|
+
export declare const autoScale: (options: ILineChartOptions, state: IState, generatedDatasets: TGeneratedLineChartDatasets) => IScales;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IGeneratedLineChartDataset, TGeneratedLineChartDatasets } from '../../line-chart.interface';
|
|
2
|
+
type TCustomOptionType = {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
} | string | string[];
|
|
5
|
+
type TDataType = IGeneratedLineChartDataset | Partial<IGeneratedLineChartDataset> | TGeneratedLineChartDatasets | Partial<TGeneratedLineChartDatasets> | any[];
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a single dataset or an array of datasets has a custom option.
|
|
8
|
+
* Iterates through each custom option defined in the customOptions parameter.
|
|
9
|
+
* Returns true if any dataset has any custom option, otherwise returns false.
|
|
10
|
+
*/
|
|
11
|
+
export declare const checkCustomOption: (data: TDataType, customOptions: TCustomOptionType) => boolean;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface IChartArea {
|
|
2
|
+
left: number | null;
|
|
3
|
+
right: number | null;
|
|
4
|
+
bottom: number | null;
|
|
5
|
+
}
|
|
6
|
+
interface IChartMeta {
|
|
7
|
+
data: Array<{
|
|
8
|
+
x: number | null;
|
|
9
|
+
y: number | null;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export interface IAlignmentContext {
|
|
13
|
+
chart: {
|
|
14
|
+
chartArea: IChartArea;
|
|
15
|
+
getDatasetMeta: (datasetIndex: number) => IChartMeta;
|
|
16
|
+
};
|
|
17
|
+
dataIndex: number;
|
|
18
|
+
datasetIndex: number;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returning boolean condition depends on label position and chart area
|
|
3
|
+
*/
|
|
4
|
+
export declare const getCondition: (x: number | null, y: number | null, left: number | null, right: number | null, bottom: number | null) => {
|
|
5
|
+
overLeftSide: boolean;
|
|
6
|
+
overRightSide: boolean;
|
|
7
|
+
overBottomSide: boolean;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IAlignmentContext } from './datalabels-alignment.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Safely extracts coordinates and chart area info for alignment
|
|
4
|
+
*/
|
|
5
|
+
export declare const getAlignmentData: (context: IAlignmentContext) => {
|
|
6
|
+
x: number | null;
|
|
7
|
+
y: number | null;
|
|
8
|
+
left: number | null;
|
|
9
|
+
right: number | null;
|
|
10
|
+
bottom: number | null;
|
|
11
|
+
};
|
package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AlignOptions } from '../../../common/enums.js';
|
|
2
|
+
import { IAlignmentContext } from './datalabels-alignment.interface.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Returning position depends on condition
|
|
5
|
+
*/
|
|
6
|
+
export declare const getPosition: () => (context: IAlignmentContext) => AlignOptions.End | AlignOptions.Start | AlignOptions.Right | AlignOptions.Left;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IState } from '../state/state.interfaces';
|
|
2
|
+
import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Generates line chart datasets based on the provided datasets, state, and options.
|
|
5
|
+
*/
|
|
6
|
+
export declare const generateLineChartDatasets: (datasets: Array<any>, state: IState, options: ILineChartOptions, { label }: {
|
|
7
|
+
label: string;
|
|
8
|
+
}) => TGeneratedLineChartDatasets;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Function that returns an object containing all the values for a specific key in an array of objects,
|
|
3
|
+
grouped by the unique values of another key in the same objects.
|
|
4
|
+
@param {Array} data - An array of objects to search for the keys.
|
|
5
|
+
@return {Object} - Returns an object with keys representing the unique values for the annotationAxis key in the data array,
|
|
6
|
+
and values representing an array of all values for the value key in the data array.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getAnnotationsData: (data: any[]) => Object;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts axis-specific data from datasets and annotations.
|
|
3
|
+
* Returns { [axisId]: unique values used on that axis across datasets and annotations }
|
|
4
|
+
*/
|
|
5
|
+
export declare const getAxesDataFromMetasets: (generatedDatasets: any, scalesKeys: any, annotationsData: any) => any;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { ICommonAnnotationsData, TChart } from '../../common/common.interface.ts';
|
|
3
|
+
export type TAxisType = 'x' | 'y' | 'x1' | 'y1';
|
|
4
|
+
interface IMinMax {
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const getAxisRangeByType: (chartRef: RefObject<TChart | null>, axesType: TAxisType, annotationsData: ICommonAnnotationsData[]) => IMinMax | null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TooltipItem } from 'chart.js';
|
|
2
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
3
|
+
import { UnusedParameter } from '../../common/common.interface';
|
|
4
|
+
/**
|
|
5
|
+
* adjusts the position of the label depends on chart area
|
|
6
|
+
*/
|
|
7
|
+
declare const getLineChartDataLabels: (options: ILineChartOptions) => {
|
|
8
|
+
display: string;
|
|
9
|
+
align: (context: import("./datalabels-alignment/datalabels-alignment.interface").IAlignmentContext) => import("../../common/enums").AlignOptions.End | import("../../common/enums").AlignOptions.Start | import("../../common/enums").AlignOptions.Right | import("../../common/enums").AlignOptions.Left;
|
|
10
|
+
formatter: (_: UnusedParameter, context: TooltipItem<any>) => any;
|
|
11
|
+
} | {
|
|
12
|
+
align?: undefined;
|
|
13
|
+
formatter?: undefined;
|
|
14
|
+
display: boolean;
|
|
15
|
+
};
|
|
16
|
+
export default getLineChartDataLabels;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IState } from '../state/state.interfaces';
|
|
2
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
3
|
+
import { ICommonScaleOptions } from '../../common/common.interface.js';
|
|
4
|
+
declare const getLineChartScales: (options: ILineChartOptions, state: IState) => Record<string, ICommonScaleOptions>;
|
|
5
|
+
export default getLineChartScales;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TooltipItem } from 'chart.js';
|
|
2
|
+
import { ChartHoverMode, ChartType } from '../../common/enums.js';
|
|
3
|
+
import { afterLabelCallback } from '../../common/helpers/chart-utils.js';
|
|
4
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
5
|
+
export declare const getUnitsFromLabel: (label: string) => string;
|
|
6
|
+
declare const getLineChartToolTips: (options: ILineChartOptions) => {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
callbacks: {};
|
|
9
|
+
mode?: undefined;
|
|
10
|
+
intersect?: undefined;
|
|
11
|
+
padding?: undefined;
|
|
12
|
+
usePointStyle?: undefined;
|
|
13
|
+
boxWidth?: undefined;
|
|
14
|
+
boxHeight?: undefined;
|
|
15
|
+
boxPadding?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
enabled: boolean | undefined;
|
|
18
|
+
mode: ChartHoverMode;
|
|
19
|
+
intersect: boolean;
|
|
20
|
+
padding: number;
|
|
21
|
+
usePointStyle: boolean;
|
|
22
|
+
boxWidth: number;
|
|
23
|
+
boxHeight: number;
|
|
24
|
+
boxPadding: number;
|
|
25
|
+
callbacks: {
|
|
26
|
+
title: ((...args: unknown[]) => unknown) | ((items: TooltipItem<ChartType.LINE>[]) => string);
|
|
27
|
+
label: ((...args: unknown[]) => unknown) | ((item: TooltipItem<ChartType.LINE>) => string);
|
|
28
|
+
afterLabel: ((...args: unknown[]) => unknown) | typeof afterLabelCallback;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default getLineChartToolTips;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TPrimitive } from '../../common/common.interface.js';
|
|
2
|
+
import { IState } from '../state/state.interfaces.js';
|
|
3
|
+
export declare const toNum: (value: string | number) => any;
|
|
4
|
+
export declare const isLessThanMax: (value: string | number, max: string | number) => boolean;
|
|
5
|
+
export declare const isGreaterThanMin: (value: string | number, min: string | number) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {'x'|'y'} axisType
|
|
9
|
+
* @param {number} [index] - axis index; optional, 0 by default
|
|
10
|
+
* @param {boolean} [hasMultiAxes] - optional, false by default
|
|
11
|
+
* @return {string} - e.g. x if chart has singular axes; x, x2 - in case of multiple axes
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateAxisId: (axisType: string, index?: number, hasMultiAxes?: boolean) => string;
|
|
14
|
+
/**
|
|
15
|
+
Get axis type from a key string.
|
|
16
|
+
@param {string} string - The key string to extract from.
|
|
17
|
+
@returns {string} e.g. x1 => x
|
|
18
|
+
*/
|
|
19
|
+
export declare const getAxisTypeFromKey: (string: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a value is a primitive value (which includes strings, numbers, booleans, and null).
|
|
22
|
+
*/
|
|
23
|
+
export declare const isPrimitiveValue: (value: TPrimitive) => value is string | number | boolean | null;
|
|
24
|
+
export declare const getChartKey: (state: IState, languageKey: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defaultTranslations } from '../../constants/default-translations';
|
|
2
|
+
/**
|
|
3
|
+
* Merges custom getTranslations with the default getTranslations.
|
|
4
|
+
* If a custom translation is provided for a key, it will override the default one.
|
|
5
|
+
* @param {object} translations - Custom getTranslations.
|
|
6
|
+
* @returns {object} - The resulting getTranslations object, containing both default and custom getTranslations.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getTranslations: (translations?: Partial<Record<keyof typeof defaultTranslations, string>>) => {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ChartEvent } from 'chart.js';
|
|
2
|
+
import type { ICommonTooltip } from '../common/common.interface.js';
|
|
3
|
+
import type { AlignOptions, Position } from '../common/enums';
|
|
4
|
+
import type { IPieChartDataset, IPieOptions } from './pie-chart.interface';
|
|
5
|
+
export interface IDefaultChartStyling {
|
|
6
|
+
width?: number | string;
|
|
7
|
+
height?: number | string;
|
|
8
|
+
maintainAspectRatio: boolean;
|
|
9
|
+
staticChartHeight: boolean;
|
|
10
|
+
performanceMode: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface IDefaultPieGraph {
|
|
13
|
+
showDataLabels: boolean;
|
|
14
|
+
stacked: boolean;
|
|
15
|
+
cutout: number | string;
|
|
16
|
+
}
|
|
17
|
+
interface IDefaultPieLegend {
|
|
18
|
+
display: boolean;
|
|
19
|
+
useDataset: boolean;
|
|
20
|
+
position: Position;
|
|
21
|
+
align: AlignOptions;
|
|
22
|
+
}
|
|
23
|
+
interface IDefaultChartOptions {
|
|
24
|
+
enableZoom: boolean;
|
|
25
|
+
enablePan: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface IDefaultInteractions {
|
|
28
|
+
onLegendClick?: (text: string, hidden: boolean) => void;
|
|
29
|
+
onHover?: (event: ChartEvent, datasetIndex: number, index: number, generatedDataset: IPieChartDataset[]) => void;
|
|
30
|
+
onUnhover?: (event?: ChartEvent, datasetIndex?: number, index?: number, generatedDataset?: IPieChartDataset[]) => void;
|
|
31
|
+
}
|
|
32
|
+
interface IDefaultChartData {
|
|
33
|
+
labels: string[];
|
|
34
|
+
datasets: IPieChartDataset[];
|
|
35
|
+
}
|
|
36
|
+
interface IDefaultPieOptions extends IPieOptions {
|
|
37
|
+
title: string | string[];
|
|
38
|
+
chartStyling: IDefaultChartStyling;
|
|
39
|
+
tooltip: ICommonTooltip;
|
|
40
|
+
graph: IDefaultPieGraph;
|
|
41
|
+
legend: IDefaultPieLegend;
|
|
42
|
+
chartOptions: IDefaultChartOptions;
|
|
43
|
+
interactions: IDefaultInteractions;
|
|
44
|
+
}
|
|
45
|
+
export interface IPieChartDefaultProps {
|
|
46
|
+
testId: string | null;
|
|
47
|
+
data: IDefaultChartData;
|
|
48
|
+
options: IDefaultPieOptions;
|
|
49
|
+
}
|
|
50
|
+
export {};
|