@oliasoft-open-source/charts-library 5.13.0 → 5.14.0-beta-2
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 -1217
- package/dist/index.js +453 -68
- 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 +3 -0
- package/dist/src/components/bar-chart/bar-chart.interface.d.ts +141 -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 +3 -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 +55 -0
- package/dist/src/components/common/common.interface.d.ts +275 -0
- package/dist/src/components/common/controls-portal.d.ts +7 -0
- package/dist/src/components/common/enums.d.ts +87 -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 +39 -0
- package/dist/src/components/common/helpers/chart-utils.d.ts +86 -0
- package/dist/src/components/common/helpers/container.d.ts +18 -0
- package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -0
- package/dist/src/components/common/helpers/download-pgn.d.ts +3 -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-custom-legend-plugin-example.d.ts +8 -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 +1 -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/text.d.ts +1 -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 +47 -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.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 +2 -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 +21 -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 +10 -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 +3 -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 +19 -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 +12 -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 +3 -0
- package/dist/src/components/line-chart/line-chart.interface.d.ts +236 -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 +109 -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 +1 -0
- package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -0
- package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +9 -0
- package/dist/src/components/line-chart/utils/get-axis-range-by-type.d.ts +10 -0
- package/dist/src/components/line-chart/utils/get-generated-labels.d.ts +2 -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 +589 -0
- package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +30 -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 +3 -0
- package/dist/src/components/pie-chart/pie-chart.interface.d.ts +58 -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 +239 -0
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +72 -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 +3 -0
- package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +111 -0
- package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +176 -0
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +21 -0
- package/package.json +9 -9
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DeepPartial, ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDataValue, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip, TAxisPosition } from '../common/common.interface';
|
|
3
|
+
export interface ILChartOptions extends ICommonChartOptions {
|
|
4
|
+
showPoints?: boolean;
|
|
5
|
+
closeOnOutsideClick?: boolean;
|
|
6
|
+
showLine?: boolean;
|
|
7
|
+
enableZoom?: boolean;
|
|
8
|
+
enablePan?: boolean;
|
|
9
|
+
enableDragAnnotation?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ILineChartGraph {
|
|
12
|
+
lineTension?: number;
|
|
13
|
+
spanGaps?: boolean;
|
|
14
|
+
showDataLabels?: boolean;
|
|
15
|
+
showMinorGridlines?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ILineChartTooltip extends ICommonTooltip {
|
|
18
|
+
hideSimulationName?: boolean;
|
|
19
|
+
scientificNotation?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface ILineChartRange {
|
|
22
|
+
min?: number;
|
|
23
|
+
max?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ILineRange {
|
|
26
|
+
[key: string]: ILineChartRange;
|
|
27
|
+
}
|
|
28
|
+
export interface ILineChartAdditionalAxesOptions {
|
|
29
|
+
chartScaleType?: 'linear' | 'logarithmic';
|
|
30
|
+
reverse?: boolean;
|
|
31
|
+
beginAtZero?: boolean;
|
|
32
|
+
stepSize?: number;
|
|
33
|
+
suggestedMin?: number;
|
|
34
|
+
suggestedMax?: number;
|
|
35
|
+
range?: ILineRange;
|
|
36
|
+
autoAxisPadding?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface IUnitOptions {
|
|
39
|
+
options: string[];
|
|
40
|
+
selectedUnit: string;
|
|
41
|
+
setSelectedUnit: () => void;
|
|
42
|
+
}
|
|
43
|
+
export interface ILineChartAxis<PositionType = TAxisPosition> {
|
|
44
|
+
id?: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
position?: PositionType;
|
|
47
|
+
color?: string | string[];
|
|
48
|
+
unit?: IUnitOptions | string;
|
|
49
|
+
stepSize?: number;
|
|
50
|
+
gridLines?: ILineChartGraph;
|
|
51
|
+
min?: number | string;
|
|
52
|
+
max?: number | string;
|
|
53
|
+
}
|
|
54
|
+
export interface ILineChartAxes {
|
|
55
|
+
x: ILineChartAxis<'top' | 'bottom'>[];
|
|
56
|
+
y: ILineChartAxis<'left' | 'right'>[];
|
|
57
|
+
[key: string]: ILineChartAxis[];
|
|
58
|
+
}
|
|
59
|
+
export interface IDepthType {
|
|
60
|
+
options: string[];
|
|
61
|
+
selectedUnit: string;
|
|
62
|
+
setSelectedUnit: () => void;
|
|
63
|
+
}
|
|
64
|
+
export interface ILineChartStyling extends ICommonStyling {
|
|
65
|
+
squareAspectRatio?: number | boolean;
|
|
66
|
+
layoutPadding?: number | {
|
|
67
|
+
top: number;
|
|
68
|
+
bottom: number;
|
|
69
|
+
left: number;
|
|
70
|
+
right: number;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface ILineInteractions extends ICommonInteractions {
|
|
74
|
+
onAnimationComplete?: () => void;
|
|
75
|
+
}
|
|
76
|
+
export interface ILineLegend extends ICommonLegend {
|
|
77
|
+
customLegend?: ICommonCustomLegend<any>;
|
|
78
|
+
usePointStyle?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface ILineChartOptions extends ICommonOptions {
|
|
81
|
+
title?: string | string[];
|
|
82
|
+
axes: ILineChartAxes;
|
|
83
|
+
scales: ICommonScales;
|
|
84
|
+
additionalAxesOptions: ILineChartAdditionalAxesOptions;
|
|
85
|
+
chartStyling: ILineChartStyling;
|
|
86
|
+
tooltip: ILineChartTooltip;
|
|
87
|
+
graph: ILineChartGraph;
|
|
88
|
+
annotations: ICommonAnnotations;
|
|
89
|
+
legend: ILineLegend;
|
|
90
|
+
chartOptions: ILChartOptions;
|
|
91
|
+
interactions: ILineInteractions;
|
|
92
|
+
dragData?: ICommonDragData;
|
|
93
|
+
depthType?: IDepthType | object;
|
|
94
|
+
}
|
|
95
|
+
type ILooseLineAxis = DeepPartial<ILineChartAxis<string>> & {
|
|
96
|
+
[key: string]: unknown;
|
|
97
|
+
stepSize?: unknown;
|
|
98
|
+
};
|
|
99
|
+
type ILooseLineAnnotation = {
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
id?: string;
|
|
102
|
+
label?: string;
|
|
103
|
+
color?: string;
|
|
104
|
+
borderColor?: string;
|
|
105
|
+
backgroundColor?: string;
|
|
106
|
+
borderWidth?: number;
|
|
107
|
+
display?: boolean;
|
|
108
|
+
adjustScaleRange?: boolean;
|
|
109
|
+
opacity?: number;
|
|
110
|
+
hideLegend?: boolean;
|
|
111
|
+
labelOffsetPx?: number;
|
|
112
|
+
annotationAxis?: string;
|
|
113
|
+
type?: string;
|
|
114
|
+
value?: number | string | null;
|
|
115
|
+
xMin?: number | string | null;
|
|
116
|
+
xMax?: number | string | null;
|
|
117
|
+
yMin?: number | string | null;
|
|
118
|
+
yMax?: number | string | null;
|
|
119
|
+
xValue?: number | string | null;
|
|
120
|
+
yValue?: number | string | null;
|
|
121
|
+
onDragStart?: (...args: unknown[]) => void;
|
|
122
|
+
onDrag?: (...args: unknown[]) => void;
|
|
123
|
+
onDragEnd?: (...args: unknown[]) => void;
|
|
124
|
+
};
|
|
125
|
+
export type ILineChartOptionsInput = Omit<DeepPartial<ILineChartOptions>, 'title' | 'axes' | 'legend' | 'chartStyling' | 'interactions' | 'graph' | 'annotations' | 'additionalAxesOptions'> & {
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
title?: unknown;
|
|
128
|
+
direction?: string;
|
|
129
|
+
axes?: {
|
|
130
|
+
x?: ILooseLineAxis[];
|
|
131
|
+
y?: ILooseLineAxis[];
|
|
132
|
+
[key: string]: ILooseLineAxis[] | undefined;
|
|
133
|
+
};
|
|
134
|
+
legend?: Omit<DeepPartial<ILineLegend>, 'position' | 'align'> & {
|
|
135
|
+
position?: string;
|
|
136
|
+
align?: string;
|
|
137
|
+
[key: string]: unknown;
|
|
138
|
+
};
|
|
139
|
+
chartStyling?: DeepPartial<ILineChartStyling> & {
|
|
140
|
+
hideControls?: boolean;
|
|
141
|
+
minHeight?: number | string;
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
};
|
|
144
|
+
interactions?: DeepPartial<ILineInteractions> & {
|
|
145
|
+
enableZoom?: boolean;
|
|
146
|
+
enablePan?: boolean;
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
};
|
|
149
|
+
graph?: DeepPartial<ILineChartGraph> & {
|
|
150
|
+
tooltip?: unknown;
|
|
151
|
+
[key: string]: unknown;
|
|
152
|
+
};
|
|
153
|
+
annotations?: (Omit<DeepPartial<ICommonAnnotations>, 'annotationsData'> & {
|
|
154
|
+
annotationsData?: ILooseLineAnnotation[];
|
|
155
|
+
}) | ILooseLineAnnotation[] | null;
|
|
156
|
+
additionalAxesOptions?: DeepPartial<ILineChartAdditionalAxesOptions> & {
|
|
157
|
+
stepSize?: unknown;
|
|
158
|
+
range?: ILineRange | ILineChartRange | Record<string, ILineChartRange | undefined>;
|
|
159
|
+
} & Record<string, unknown>;
|
|
160
|
+
};
|
|
161
|
+
export interface ILineChartDataInput extends Omit<ILineChartData, 'data' | 'options'> {
|
|
162
|
+
data?: Omit<DeepPartial<ILineChartData['data']>, 'datasets'> & {
|
|
163
|
+
datasets?: Array<(DeepPartial<ILineChartDataset> & {
|
|
164
|
+
lineTension?: number | string;
|
|
165
|
+
fill?: boolean | string | Record<string, unknown>;
|
|
166
|
+
pointStyle?: unknown;
|
|
167
|
+
showPoint?: boolean;
|
|
168
|
+
showPoints?: boolean;
|
|
169
|
+
lineHeight?: number;
|
|
170
|
+
data?: Array<DeepPartial<ICommonDataValue> | null>;
|
|
171
|
+
[key: string]: unknown;
|
|
172
|
+
}) | object | null> | object;
|
|
173
|
+
};
|
|
174
|
+
options?: ILineChartOptionsInput;
|
|
175
|
+
}
|
|
176
|
+
export interface ILineChartDataset extends ICommonDataset {
|
|
177
|
+
lineTension?: number;
|
|
178
|
+
pointBackgroundColor?: string;
|
|
179
|
+
pointRadius?: number;
|
|
180
|
+
pointHoverRadius?: number;
|
|
181
|
+
pointHitRadius?: number;
|
|
182
|
+
fill?: boolean;
|
|
183
|
+
xAxisID?: string;
|
|
184
|
+
yAxisID?: string;
|
|
185
|
+
formation?: boolean;
|
|
186
|
+
displayGroup?: string | number;
|
|
187
|
+
pointStyle?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ILineChartData extends ICommonData {
|
|
190
|
+
data?: {
|
|
191
|
+
datasets: ILineChartDataset[];
|
|
192
|
+
};
|
|
193
|
+
options: ILineChartOptions;
|
|
194
|
+
persistenceId?: string;
|
|
195
|
+
controlsPortalId?: string;
|
|
196
|
+
}
|
|
197
|
+
export interface ILineChartProps {
|
|
198
|
+
chart: ILineChartDataInput;
|
|
199
|
+
table?: ReactNode;
|
|
200
|
+
headerComponent?: ReactNode;
|
|
201
|
+
subheaderComponent?: ReactNode;
|
|
202
|
+
}
|
|
203
|
+
export interface LineChart extends ILineChartDataInput {
|
|
204
|
+
}
|
|
205
|
+
export interface IGeneratedLineChartDataset {
|
|
206
|
+
label?: string;
|
|
207
|
+
data: ICommonDataValue[];
|
|
208
|
+
showLine?: boolean;
|
|
209
|
+
lineTension: number;
|
|
210
|
+
spanGaps: boolean;
|
|
211
|
+
borderWidth: number;
|
|
212
|
+
borderDash: number[];
|
|
213
|
+
borderJoinStyle: 'round' | 'bevel' | 'miter';
|
|
214
|
+
borderColor: string;
|
|
215
|
+
backgroundColor: string | string[];
|
|
216
|
+
pointBackgroundColor: string;
|
|
217
|
+
pointRadius: number;
|
|
218
|
+
pointHoverRadius: number;
|
|
219
|
+
pointHitRadius: number;
|
|
220
|
+
isAnnotation?: boolean;
|
|
221
|
+
annotationType?: string;
|
|
222
|
+
annotationIndex?: number;
|
|
223
|
+
annotationLabel?: string;
|
|
224
|
+
annotationBackgroundColor?: string;
|
|
225
|
+
annotationPointBackgroundColor?: string;
|
|
226
|
+
annotationBorderColor?: string;
|
|
227
|
+
annotationBorderDash?: number[];
|
|
228
|
+
annotationBorderWidth?: number;
|
|
229
|
+
displayGroup?: string | number;
|
|
230
|
+
hideLegend?: boolean;
|
|
231
|
+
pointStyle?: string;
|
|
232
|
+
xAxisID?: string;
|
|
233
|
+
yAxisID?: string;
|
|
234
|
+
}
|
|
235
|
+
export type TGeneratedLineChartDatasets = IGeneratedLineChartDataset[];
|
|
236
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChartType, Plugin } from 'chart.js';
|
|
2
|
+
import { TCalloutConnector } from './helpers';
|
|
3
|
+
declare module 'chart.js' {
|
|
4
|
+
interface PluginOptionsByType<TType extends ChartType> {
|
|
5
|
+
calloutConnectorPlugin?: {
|
|
6
|
+
enableCalloutAnnotation?: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const calloutConnectorPlugin: Plugin;
|
|
11
|
+
export type { TCalloutConnector };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type TCalloutConnector = {
|
|
2
|
+
enabled?: boolean | ((context: {
|
|
3
|
+
chart: any;
|
|
4
|
+
labelEl?: TAnnotationLike;
|
|
5
|
+
fromEl?: TAnnotationLike;
|
|
6
|
+
option?: any;
|
|
7
|
+
}) => boolean);
|
|
8
|
+
fromId: string;
|
|
9
|
+
strokeStyle?: string;
|
|
10
|
+
lineWidth?: number;
|
|
11
|
+
lineDash?: number[];
|
|
12
|
+
startOffset?: number;
|
|
13
|
+
endOffset?: number;
|
|
14
|
+
anchor?: {
|
|
15
|
+
position?: string;
|
|
16
|
+
xAdjust?: number;
|
|
17
|
+
yAdjust?: number;
|
|
18
|
+
labelOffsetPx?: number;
|
|
19
|
+
tickSize?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type TAnnotationLike = {
|
|
23
|
+
centerX: number;
|
|
24
|
+
centerY: number;
|
|
25
|
+
width?: number;
|
|
26
|
+
height?: number;
|
|
27
|
+
options?: {
|
|
28
|
+
display: boolean;
|
|
29
|
+
radius?: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type TConnectorPoints = {
|
|
33
|
+
startX: number;
|
|
34
|
+
startY: number;
|
|
35
|
+
endX: number;
|
|
36
|
+
endY: number;
|
|
37
|
+
tickStartX: number;
|
|
38
|
+
tickStartY: number;
|
|
39
|
+
tickEndX: number;
|
|
40
|
+
tickEndY: number;
|
|
41
|
+
};
|
|
42
|
+
export declare const computeConnectorPoints: (fromEl: TAnnotationLike, labelEl: TAnnotationLike, connector: TCalloutConnector) => TConnectorPoints;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Chart, ChartConfiguration, Plugin } from 'chart.js';
|
|
2
|
+
import { Position } from '../../common/enums';
|
|
3
|
+
interface CustomChartConfiguration extends ChartConfiguration {
|
|
4
|
+
showLabel?: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
xOffset: number;
|
|
8
|
+
yOffset: number;
|
|
9
|
+
lineHeight: number;
|
|
10
|
+
maxWidth: number;
|
|
11
|
+
position: Position;
|
|
12
|
+
}
|
|
13
|
+
export declare const chartAreaTextPlugin: {
|
|
14
|
+
id: string;
|
|
15
|
+
beforeDraw: (chart: Chart, _args: Plugin, options: CustomChartConfiguration) => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chart, Scale } from 'chart.js';
|
|
2
|
+
export declare const getLargestMajorTickWidth: (majorTickPositions: number[]) => number;
|
|
3
|
+
export declare const isValidPosition: (minorTickPosition: number, majorTickPositions: number[], scale: Scale) => boolean;
|
|
4
|
+
export declare const getMinorTickPositions: (majorTickPositions: number[], scale: Scale) => number[];
|
|
5
|
+
export declare const chartMinorGridlinesPlugin: {
|
|
6
|
+
id: string;
|
|
7
|
+
beforeDatasetsDraw: (chart: Chart) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Chart } from 'chart.js';
|
|
2
|
+
import { TLineMarkerTick, TLineMarkerDirection, TStickSide } from './types.ts';
|
|
3
|
+
export type TDrawLineArgs = {
|
|
4
|
+
chart: Chart;
|
|
5
|
+
x1: number;
|
|
6
|
+
y1: number;
|
|
7
|
+
x2: number;
|
|
8
|
+
y2: number;
|
|
9
|
+
color: string;
|
|
10
|
+
opacity: number;
|
|
11
|
+
lineWidth: number;
|
|
12
|
+
lineDash: number[];
|
|
13
|
+
};
|
|
14
|
+
export declare const drawLineSegment: ({ chart, x1, y1, x2, y2, color, opacity, lineWidth, lineDash, }: TDrawLineArgs) => {
|
|
15
|
+
x1: number;
|
|
16
|
+
y1: number;
|
|
17
|
+
x2: number;
|
|
18
|
+
y2: number;
|
|
19
|
+
};
|
|
20
|
+
export type TDrawTickArgs = {
|
|
21
|
+
ctx: CanvasRenderingContext2D;
|
|
22
|
+
chartArea: {
|
|
23
|
+
left: number;
|
|
24
|
+
right: number;
|
|
25
|
+
top: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
};
|
|
28
|
+
direction: TLineMarkerDirection;
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
side: TStickSide;
|
|
32
|
+
reverse?: boolean;
|
|
33
|
+
labelY?: number;
|
|
34
|
+
tick: TLineMarkerTick;
|
|
35
|
+
defaultColor: string;
|
|
36
|
+
defaultFont: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const drawTick: (args: TDrawTickArgs) => void;
|
|
39
|
+
export declare const getTickLabelHeight: (tick: TLineMarkerTick, defaultFont: string) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChartType, Plugin } from 'chart.js';
|
|
2
|
+
import { TLineMarkersOptions } from './types';
|
|
3
|
+
declare module 'chart.js' {
|
|
4
|
+
interface PluginOptionsByType<TType extends ChartType> {
|
|
5
|
+
lineMarkersPlugin?: {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
} | TLineMarkersOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const lineMarkersPlugin: Plugin;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export declare enum LineMarkerSide {
|
|
2
|
+
Left = "left",
|
|
3
|
+
Right = "right"
|
|
4
|
+
}
|
|
5
|
+
export declare enum LineMarkerDirection {
|
|
6
|
+
Vertical = "vertical",
|
|
7
|
+
Horizontal = "horizontal"
|
|
8
|
+
}
|
|
9
|
+
export declare enum LineMarkerLabelPosition {
|
|
10
|
+
Left = "left",
|
|
11
|
+
Right = "right",
|
|
12
|
+
Top = "top",
|
|
13
|
+
Bottom = "bottom",
|
|
14
|
+
OnLine = "onLine"
|
|
15
|
+
}
|
|
16
|
+
export declare enum LineMarkerTextAlign {
|
|
17
|
+
Left = "left",
|
|
18
|
+
Right = "right",
|
|
19
|
+
Center = "center"
|
|
20
|
+
}
|
|
21
|
+
export type TStickSide = LineMarkerSide;
|
|
22
|
+
export type TLineMarkerDirection = LineMarkerDirection;
|
|
23
|
+
export type TLineMarkerLabelPosition = LineMarkerLabelPosition;
|
|
24
|
+
export type TLineMarkerTextAlign = LineMarkerTextAlign;
|
|
25
|
+
export type TLineMarkerTick = {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
label?: string | string[];
|
|
28
|
+
color?: string;
|
|
29
|
+
font?: string;
|
|
30
|
+
labelOffsetPx?: number;
|
|
31
|
+
labelPosition?: TLineMarkerLabelPosition;
|
|
32
|
+
side?: TStickSide;
|
|
33
|
+
reverse?: boolean;
|
|
34
|
+
sizePx?: number;
|
|
35
|
+
};
|
|
36
|
+
export type TMarkerExtraItem = {
|
|
37
|
+
id?: string;
|
|
38
|
+
display?: boolean;
|
|
39
|
+
yScaleID?: string;
|
|
40
|
+
yValue?: number;
|
|
41
|
+
value?: number;
|
|
42
|
+
lengthPx?: number;
|
|
43
|
+
side?: TStickSide;
|
|
44
|
+
reverse?: boolean;
|
|
45
|
+
color?: string;
|
|
46
|
+
opacity?: number;
|
|
47
|
+
lineWidth?: number;
|
|
48
|
+
lineDash?: number[];
|
|
49
|
+
tick?: TLineMarkerTick;
|
|
50
|
+
};
|
|
51
|
+
export type TLineMarkerItem = {
|
|
52
|
+
id?: string;
|
|
53
|
+
direction?: TLineMarkerDirection;
|
|
54
|
+
xScaleID?: string;
|
|
55
|
+
yScaleID?: string;
|
|
56
|
+
xValue?: number;
|
|
57
|
+
yValue?: number;
|
|
58
|
+
yStartValue?: number;
|
|
59
|
+
yEndValue?: number;
|
|
60
|
+
xStartValue?: number;
|
|
61
|
+
xEndValue?: number;
|
|
62
|
+
lengthPx?: number;
|
|
63
|
+
value?: number;
|
|
64
|
+
label?: string | string[];
|
|
65
|
+
font?: string;
|
|
66
|
+
labelOffsetPx?: number;
|
|
67
|
+
stickToEdge?: boolean;
|
|
68
|
+
stickToGroup?: boolean;
|
|
69
|
+
stickSide?: TStickSide;
|
|
70
|
+
groupOffsetPx?: number;
|
|
71
|
+
reverse?: boolean;
|
|
72
|
+
color?: string;
|
|
73
|
+
opacity?: number;
|
|
74
|
+
lineWidth?: number;
|
|
75
|
+
lineDash?: number[];
|
|
76
|
+
startTick?: TLineMarkerTick;
|
|
77
|
+
endTick?: TLineMarkerTick;
|
|
78
|
+
extras?: TMarkerExtraItem[];
|
|
79
|
+
display?: boolean;
|
|
80
|
+
};
|
|
81
|
+
export type TLineMarkersOptions = {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
itemGapPx?: number;
|
|
84
|
+
edgePaddingPx?: number;
|
|
85
|
+
horizontalLineLengthPx?: number;
|
|
86
|
+
lineDirection?: TLineMarkerDirection;
|
|
87
|
+
labelCollisionPx?: number;
|
|
88
|
+
labelCollisionClusterXPx?: number;
|
|
89
|
+
enableLabelCollisionResolver?: boolean;
|
|
90
|
+
stickToEdge?: boolean;
|
|
91
|
+
stickToGroup?: boolean;
|
|
92
|
+
stickSide?: TStickSide;
|
|
93
|
+
reverse?: boolean;
|
|
94
|
+
xValue?: number;
|
|
95
|
+
yValue?: number;
|
|
96
|
+
yEndValue?: number;
|
|
97
|
+
xStartValue?: number;
|
|
98
|
+
xEndValue?: number;
|
|
99
|
+
lengthPx?: number;
|
|
100
|
+
yStartValue?: number;
|
|
101
|
+
color?: string;
|
|
102
|
+
opacity?: number;
|
|
103
|
+
lineWidth?: number;
|
|
104
|
+
lineDash?: number[];
|
|
105
|
+
startTick?: TLineMarkerTick;
|
|
106
|
+
endTick?: TLineMarkerTick;
|
|
107
|
+
items?: TLineMarkerItem[];
|
|
108
|
+
};
|
|
109
|
+
export type ILineMarkersAnnotation = TLineMarkersOptions;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Chart, Scale } from 'chart.js';
|
|
2
|
+
import { TStickSide } from './types';
|
|
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 { Chart } from 'chart.js';
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
import { IState } from './state.interfaces';
|
|
4
|
+
export interface IGetInitAxes {
|
|
5
|
+
chartRef: RefObject<Chart>;
|
|
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 {};
|