@oliasoft-open-source/charts-library 3.8.0-beta-3 → 3.8.1-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.
@@ -0,0 +1,302 @@
1
+ import { Dispatch, RefObject } from 'react';
2
+ import { Chart } from 'chart.js';
3
+ import { IState } from '../state/state.interfaces';
4
+ import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
5
+ import { ChartHoverMode, Events, PanZoomMode, PointStyle } from '../../common/helpers/enums';
6
+ interface IUseChartOptions {
7
+ chartRef: RefObject<Chart>;
8
+ state: IState;
9
+ options: ILineChartOptions;
10
+ dispatch: Dispatch<any>;
11
+ generatedDatasets: ILineChartDataset[];
12
+ }
13
+ /**
14
+ * Custom hook to generate chart options.
15
+ */
16
+ export declare const useChartOptions: ({ chartRef, state, options, dispatch, generatedDatasets, }: IUseChartOptions) => {
17
+ layout: {
18
+ padding: string | number | {
19
+ top: number;
20
+ bottom: number;
21
+ left: number;
22
+ right: number;
23
+ } | undefined;
24
+ };
25
+ onHover: (evt: import("chart.js").ChartEvent, hoveredItems: import("../../common/common.interface").ICommonHoveredItems[]) => void;
26
+ maintainAspectRatio: boolean | undefined;
27
+ aspectRatio: number;
28
+ animation: boolean | {
29
+ duration: number;
30
+ onComplete: (() => void) | undefined;
31
+ };
32
+ hover: {
33
+ mode: ChartHoverMode;
34
+ intersect: boolean;
35
+ };
36
+ elements: {
37
+ line: {
38
+ pointStyle: PointStyle;
39
+ showLine: boolean;
40
+ };
41
+ };
42
+ scales: any;
43
+ plugins: {
44
+ datalabels: {
45
+ display: string;
46
+ align: (context: any) => import("../../common/helpers/enums").AlignOptions.End | import("../../common/helpers/enums").AlignOptions.Start | import("../../common/helpers/enums").AlignOptions.Right | import("../../common/helpers/enums").AlignOptions.Left;
47
+ formatter: (_value: any, context: import("chart.js").TooltipItem<any>) => any;
48
+ } | {
49
+ display: boolean;
50
+ align?: undefined;
51
+ formatter?: undefined;
52
+ };
53
+ annotation: {
54
+ annotations: {
55
+ annotationAxis?: string | undefined;
56
+ color?: string | undefined;
57
+ type?: string | undefined;
58
+ adjustScaleRange?: boolean | undefined;
59
+ label?: string | undefined;
60
+ value?: number | undefined;
61
+ };
62
+ };
63
+ zoom: {
64
+ pan: {
65
+ enabled: boolean;
66
+ mode: PanZoomMode;
67
+ onPanComplete(): void;
68
+ };
69
+ zoom: {
70
+ mode: PanZoomMode;
71
+ drag: {
72
+ enabled: boolean;
73
+ threshold: number;
74
+ backgroundColor: string;
75
+ borderColor: string;
76
+ borderWidth: number;
77
+ };
78
+ onZoomComplete(): void;
79
+ };
80
+ };
81
+ tooltip: {
82
+ enabled: boolean;
83
+ mode: ChartHoverMode;
84
+ intersect: boolean;
85
+ padding: number;
86
+ usePointStyle: boolean;
87
+ boxWidth: number;
88
+ boxHeight: number;
89
+ boxPadding: number;
90
+ callbacks: {
91
+ title: (tooltipItem: any, _data: any) => string;
92
+ label: (tooltipItem: any) => string;
93
+ afterLabel: (tooltipItem: Record<string, any>) => string;
94
+ };
95
+ };
96
+ legend: {
97
+ display: boolean;
98
+ position: import("../../common/helpers/enums").Position;
99
+ align: string | undefined;
100
+ labels: {
101
+ boxHeight: number;
102
+ boxWidth: number | undefined;
103
+ usePointStyle: boolean | undefined;
104
+ };
105
+ onClick: (_e: any, legendItem: any) => void;
106
+ };
107
+ customLegendPlugin: {
108
+ htmlLegend: {
109
+ containerID: string;
110
+ } | null | undefined;
111
+ };
112
+ chartAreaBorder: {
113
+ borderColor: string;
114
+ };
115
+ chartAreaText: {
116
+ showLabel: boolean | undefined;
117
+ text: string | string[] | undefined;
118
+ position: string | undefined;
119
+ fontSize: number | undefined;
120
+ xOffset: number | undefined;
121
+ yOffset: number | undefined;
122
+ maxWidth: number | undefined;
123
+ lineHeight: number | undefined;
124
+ };
125
+ } | {
126
+ dragData: {
127
+ dragX: boolean | undefined;
128
+ dragY: boolean | undefined;
129
+ round: boolean | undefined;
130
+ showTooltip: boolean | undefined;
131
+ onDragStart: () => void;
132
+ onDrag: () => void;
133
+ onDragEnd: () => void;
134
+ };
135
+ datalabels: {
136
+ display: string;
137
+ align: (context: any) => import("../../common/helpers/enums").AlignOptions.End | import("../../common/helpers/enums").AlignOptions.Start | import("../../common/helpers/enums").AlignOptions.Right | import("../../common/helpers/enums").AlignOptions.Left;
138
+ formatter: (_value: any, context: import("chart.js").TooltipItem<any>) => any;
139
+ } | {
140
+ display: boolean;
141
+ align?: undefined;
142
+ formatter?: undefined;
143
+ };
144
+ annotation: {
145
+ annotations: {
146
+ annotationAxis?: string | undefined;
147
+ color?: string | undefined;
148
+ type?: string | undefined;
149
+ adjustScaleRange?: boolean | undefined;
150
+ label?: string | undefined;
151
+ value?: number | undefined;
152
+ };
153
+ };
154
+ zoom: {
155
+ pan: {
156
+ enabled: boolean;
157
+ mode: PanZoomMode;
158
+ onPanComplete(): void;
159
+ };
160
+ zoom: {
161
+ mode: PanZoomMode;
162
+ drag: {
163
+ enabled: boolean;
164
+ threshold: number;
165
+ backgroundColor: string;
166
+ borderColor: string;
167
+ borderWidth: number;
168
+ };
169
+ onZoomComplete(): void;
170
+ };
171
+ };
172
+ tooltip: {
173
+ enabled: boolean;
174
+ mode: ChartHoverMode;
175
+ intersect: boolean;
176
+ padding: number;
177
+ usePointStyle: boolean;
178
+ boxWidth: number;
179
+ boxHeight: number;
180
+ boxPadding: number;
181
+ callbacks: {
182
+ title: (tooltipItem: any, _data: any) => string;
183
+ label: (tooltipItem: any) => string;
184
+ afterLabel: (tooltipItem: Record<string, any>) => string;
185
+ };
186
+ };
187
+ legend: {
188
+ display: boolean;
189
+ position: import("../../common/helpers/enums").Position;
190
+ align: string | undefined;
191
+ labels: {
192
+ boxHeight: number;
193
+ boxWidth: number | undefined;
194
+ usePointStyle: boolean | undefined;
195
+ };
196
+ onClick: (_e: any, legendItem: any) => void;
197
+ };
198
+ customLegendPlugin: {
199
+ htmlLegend: {
200
+ containerID: string;
201
+ } | null | undefined;
202
+ };
203
+ chartAreaBorder: {
204
+ borderColor: string;
205
+ };
206
+ chartAreaText: {
207
+ showLabel: boolean | undefined;
208
+ text: string | string[] | undefined;
209
+ position: string | undefined;
210
+ fontSize: number | undefined;
211
+ xOffset: number | undefined;
212
+ yOffset: number | undefined;
213
+ maxWidth: number | undefined;
214
+ lineHeight: number | undefined;
215
+ };
216
+ } | {
217
+ dragData?: undefined;
218
+ datalabels: {
219
+ display: string;
220
+ align: (context: any) => import("../../common/helpers/enums").AlignOptions.End | import("../../common/helpers/enums").AlignOptions.Start | import("../../common/helpers/enums").AlignOptions.Right | import("../../common/helpers/enums").AlignOptions.Left;
221
+ formatter: (_value: any, context: import("chart.js").TooltipItem<any>) => any;
222
+ } | {
223
+ display: boolean;
224
+ align?: undefined;
225
+ formatter?: undefined;
226
+ };
227
+ annotation: {
228
+ annotations: {
229
+ annotationAxis?: string | undefined;
230
+ color?: string | undefined;
231
+ type?: string | undefined;
232
+ adjustScaleRange?: boolean | undefined;
233
+ label?: string | undefined;
234
+ value?: number | undefined;
235
+ };
236
+ };
237
+ zoom: {
238
+ pan: {
239
+ enabled: boolean;
240
+ mode: PanZoomMode;
241
+ onPanComplete(): void;
242
+ };
243
+ zoom: {
244
+ mode: PanZoomMode;
245
+ drag: {
246
+ enabled: boolean;
247
+ threshold: number;
248
+ backgroundColor: string;
249
+ borderColor: string;
250
+ borderWidth: number;
251
+ };
252
+ onZoomComplete(): void;
253
+ };
254
+ };
255
+ tooltip: {
256
+ enabled: boolean;
257
+ mode: ChartHoverMode;
258
+ intersect: boolean;
259
+ padding: number;
260
+ usePointStyle: boolean;
261
+ boxWidth: number;
262
+ boxHeight: number;
263
+ boxPadding: number;
264
+ callbacks: {
265
+ title: (tooltipItem: any, _data: any) => string;
266
+ label: (tooltipItem: any) => string;
267
+ afterLabel: (tooltipItem: Record<string, any>) => string;
268
+ };
269
+ };
270
+ legend: {
271
+ display: boolean;
272
+ position: import("../../common/helpers/enums").Position;
273
+ align: string | undefined;
274
+ labels: {
275
+ boxHeight: number;
276
+ boxWidth: number | undefined;
277
+ usePointStyle: boolean | undefined;
278
+ };
279
+ onClick: (_e: any, legendItem: any) => void;
280
+ };
281
+ customLegendPlugin: {
282
+ htmlLegend: {
283
+ containerID: string;
284
+ } | null | undefined;
285
+ };
286
+ chartAreaBorder: {
287
+ borderColor: string;
288
+ };
289
+ chartAreaText: {
290
+ showLabel: boolean | undefined;
291
+ text: string | string[] | undefined;
292
+ position: string | undefined;
293
+ fontSize: number | undefined;
294
+ xOffset: number | undefined;
295
+ yOffset: number | undefined;
296
+ maxWidth: number | undefined;
297
+ lineHeight: number | undefined;
298
+ };
299
+ };
300
+ events: Events[];
301
+ };
302
+ export {};
@@ -1,4 +1,4 @@
1
- import { ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip } from '../common/common.interface';
1
+ import { ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDataValue, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip } from '../common/common.interface';
2
2
  export interface ILChartOptions extends ICommonChartOptions {
3
3
  showPoints: boolean;
4
4
  closeOnOutsideClick: boolean;
@@ -67,16 +67,6 @@ export interface ILineLegend extends ICommonLegend {
67
67
  customLegend?: ICommonCustomLegend<any>;
68
68
  usePointStyle?: boolean;
69
69
  }
70
- interface IPointEllipsisAnnotation {
71
- radiusX?: number;
72
- radiusY?: number;
73
- color?: string;
74
- rotation?: number;
75
- lineWidth?: number;
76
- }
77
- export interface ILineAnnotation extends ICommonAnnotations {
78
- pointEllipsisAnnotation?: IPointEllipsisAnnotation;
79
- }
80
70
  export interface ILineChartOptions extends ICommonOptions {
81
71
  title?: string | string[];
82
72
  axes: ILineChartAxes;
@@ -85,13 +75,22 @@ export interface ILineChartOptions extends ICommonOptions {
85
75
  chartStyling: ILineChartStyling;
86
76
  tooltip: ILineChartTooltip;
87
77
  graph: ILineChartGraph;
88
- annotations: ILineAnnotation;
78
+ annotations: ICommonAnnotations;
89
79
  legend: ILineLegend;
90
80
  chartOptions: ILChartOptions;
91
81
  interactions: ILineInteractions;
92
82
  dragData?: ICommonDragData;
93
83
  depthType?: IDepthType | object;
94
84
  }
85
+ export interface IEllipseAnnotation {
86
+ xMin: number;
87
+ xMax: number;
88
+ yMin: number;
89
+ yMax: number;
90
+ borderColor?: string;
91
+ backgroundColor?: string;
92
+ rotation?: number;
93
+ }
95
94
  export interface ILineChartDataset extends ICommonDataset {
96
95
  lineTension?: number;
97
96
  pointBackgroundColor?: string;
@@ -103,6 +102,10 @@ export interface ILineChartDataset extends ICommonDataset {
103
102
  formation?: boolean;
104
103
  displayGroup?: any;
105
104
  pointStyle?: string;
105
+ borderDash?: number[];
106
+ showPoints?: boolean;
107
+ showLine?: boolean;
108
+ ellipseAnnotations?: IEllipseAnnotation[];
106
109
  }
107
110
  export interface ILineChartData extends ICommonData {
108
111
  data?: {
@@ -116,16 +119,20 @@ export interface ILineChartProps {
116
119
  chart: ILineChartData;
117
120
  table?: any;
118
121
  }
119
- export interface IEllipseOptions {
120
- radiusX?: number;
121
- radiusY?: number;
122
- rotation?: number;
123
- lineWidth?: number;
124
- color?: string;
125
- }
126
- export interface IDatasetDataPoint {
127
- x: number;
128
- y: number;
129
- ellipseOptions?: IEllipseOptions;
130
- }
131
- export {};
122
+ export interface IGeneratedLineChartDataset {
123
+ label: string;
124
+ data: ICommonDataValue[];
125
+ showLine: boolean;
126
+ lineTension: number;
127
+ spanGaps: boolean;
128
+ borderWidth: number;
129
+ borderDash: number[];
130
+ borderJoinStyle: 'round' | 'bevel' | 'miter';
131
+ borderColor: string;
132
+ backgroundColor: string | string[];
133
+ pointBackgroundColor: string;
134
+ pointRadius: number;
135
+ pointHoverRadius: number;
136
+ pointHitRadius: number;
137
+ }
138
+ export type TGeneratedLineChartDatasets = IGeneratedLineChartDataset[];
@@ -546,50 +546,18 @@ export namespace PointEllipsisAnnotation {
546
546
  export namespace data_11 {
547
547
  const datasets_11: {
548
548
  label: string;
549
- showEllipsesAnnotation: boolean;
550
549
  data: {
551
550
  x: number;
552
551
  y: number;
553
- ellipseOptions: {
554
- radiusX: number;
555
- radiusY: number;
556
- rotation: number;
557
- };
558
552
  }[];
559
553
  }[];
560
554
  export { datasets_11 as datasets };
561
555
  }
562
556
  export { data_11 as data };
563
557
  export namespace options_18 {
564
- export namespace additionalAxesOptions_4 {
565
- export namespace range_1 {
566
- export namespace x_5 {
567
- const min_2: number;
568
- export { min_2 as min };
569
- const max_2: number;
570
- export { max_2 as max };
571
- }
572
- export { x_5 as x };
573
- export namespace y_4 {
574
- const min_3: number;
575
- export { min_3 as min };
576
- const max_3: number;
577
- export { max_3 as max };
578
- }
579
- export { y_4 as y };
580
- }
581
- export { range_1 as range };
582
- }
583
- export { additionalAxesOptions_4 as additionalAxesOptions };
584
558
  export namespace annotations_1 {
585
559
  const showAnnotations_1: boolean;
586
560
  export { showAnnotations_1 as showAnnotations };
587
- export namespace pointEllipsisAnnotation {
588
- export { DEGTORAD as rotation };
589
- export const radiusX: number;
590
- export const radiusY: number;
591
- export const lineWidth: number;
592
- }
593
561
  }
594
562
  export { annotations_1 as annotations };
595
563
  }
@@ -918,26 +886,26 @@ export namespace HideIrregularMajorAxisTicks {
918
886
  export { showMinorGridlines_1 as showMinorGridlines };
919
887
  }
920
888
  export { graph_2 as graph };
921
- export namespace additionalAxesOptions_5 {
922
- export namespace range_2 {
923
- export namespace x_6 {
924
- const min_4: number;
925
- export { min_4 as min };
926
- const max_4: number;
927
- export { max_4 as max };
889
+ export namespace additionalAxesOptions_4 {
890
+ export namespace range_1 {
891
+ export namespace x_5 {
892
+ const min_2: number;
893
+ export { min_2 as min };
894
+ const max_2: number;
895
+ export { max_2 as max };
928
896
  }
929
- export { x_6 as x };
930
- export namespace y_5 {
931
- const min_5: number;
932
- export { min_5 as min };
933
- const max_5: number;
934
- export { max_5 as max };
897
+ export { x_5 as x };
898
+ export namespace y_4 {
899
+ const min_3: number;
900
+ export { min_3 as min };
901
+ const max_3: number;
902
+ export { max_3 as max };
935
903
  }
936
- export { y_5 as y };
904
+ export { y_4 as y };
937
905
  }
938
- export { range_2 as range };
906
+ export { range_1 as range };
939
907
  }
940
- export { additionalAxesOptions_5 as additionalAxesOptions };
908
+ export { additionalAxesOptions_4 as additionalAxesOptions };
941
909
  }
942
910
  export { options_29 as options };
943
911
  }
@@ -1030,14 +998,14 @@ export namespace TestLongTooltip {
1030
998
  }
1031
999
  export { chartStyling_8 as chartStyling };
1032
1000
  export namespace axes_4 {
1033
- const x_7: {
1001
+ const x_6: {
1034
1002
  label: string;
1035
1003
  }[];
1036
- export { x_7 as x };
1037
- const y_6: {
1004
+ export { x_6 as x };
1005
+ const y_5: {
1038
1006
  label: string;
1039
1007
  }[];
1040
- export { y_6 as y };
1008
+ export { y_5 as y };
1041
1009
  }
1042
1010
  export { axes_4 as axes };
1043
1011
  }
@@ -1106,22 +1074,22 @@ export namespace PartialRange {
1106
1074
  }
1107
1075
  export { data_20 as data };
1108
1076
  export namespace options_33 {
1109
- export namespace additionalAxesOptions_6 {
1110
- export namespace range_3 {
1111
- export namespace x_8 {
1112
- const max_6: number;
1113
- export { max_6 as max };
1077
+ export namespace additionalAxesOptions_5 {
1078
+ export namespace range_2 {
1079
+ export namespace x_7 {
1080
+ const max_4: number;
1081
+ export { max_4 as max };
1114
1082
  }
1115
- export { x_8 as x };
1116
- export namespace y_7 {
1117
- const min_6: number;
1118
- export { min_6 as min };
1083
+ export { x_7 as x };
1084
+ export namespace y_6 {
1085
+ const min_4: number;
1086
+ export { min_4 as min };
1119
1087
  }
1120
- export { y_7 as y };
1088
+ export { y_6 as y };
1121
1089
  }
1122
- export { range_3 as range };
1090
+ export { range_2 as range };
1123
1091
  }
1124
- export { additionalAxesOptions_6 as additionalAxesOptions };
1092
+ export { additionalAxesOptions_5 as additionalAxesOptions };
1125
1093
  }
1126
1094
  export { options_33 as options };
1127
1095
  }
@@ -1207,6 +1175,5 @@ export namespace Tension {
1207
1175
  }
1208
1176
  import { LineChart } from './line-chart';
1209
1177
  declare namespace basicChart { }
1210
- import { DEGTORAD } from './plugins/plugin-constants';
1211
1178
  declare const customLegendContainerID: "custom-legend-container";
1212
1179
  declare const testComponent: import("react/jsx-runtime").JSX.Element;
@@ -9,4 +9,3 @@ export declare const TextLabelPosition: {
9
9
  BOTTOM_CENTER: string;
10
10
  BOTTOM_RIGHT: string;
11
11
  };
12
- export declare const DEGTORAD = 90;
@@ -1,7 +1,7 @@
1
1
  type TCustomOptionType = {
2
2
  [key: string]: string;
3
3
  } | string | string[];
4
- type TDataType = Record<string, unknown> | Array<any>;
4
+ export type TDataType = Record<string, unknown> | Array<any>;
5
5
  /**
6
6
  * Checks if a single dataset or an array of datasets has a custom option.
7
7
  * Iterates through each custom option defined in the customOptions parameter.
@@ -0,0 +1 @@
1
+ export declare const ellipsisAnnotation: (datasets: any[]) => Record<string, any>;
@@ -1,12 +1,7 @@
1
1
  import { IState } from '../state/state.interfaces';
2
- import { ILineChartOptions } from '../line-chart.interface';
2
+ import { ILineChartDataset, ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
3
3
  /**
4
4
  * Generates line chart datasets based on the provided datasets, state, and options.
5
- *
6
- * @param {Array} datasets - The initial datasets for the line chart.
7
- * @param {Object} state - The state object containing chart settings (e.g., lineEnabled, pointsEnabled, axes).
8
- * @param {Object} options - The options object containing additional settings (e.g., annotations, graph).
9
- * @param {Object} translations - The getTranslations object with the label property
10
- * @returns {Array} - The generated line chart datasets with applied settings and configurations.
5
+ * datasets - The initial datasets for the line chart.
11
6
  */
12
- export declare const generateLineChartDatasets: (datasets: Array<any>, state: IState, options: ILineChartOptions, { label }: any) => any[];
7
+ export declare const generateLineChartDatasets: (datasets: ILineChartDataset[], state: IState, options: ILineChartOptions, { label }: any) => TGeneratedLineChartDatasets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "3.8.0-beta-3",
3
+ "version": "3.8.1-beta-1",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
6
6
  "resolutions": {
@@ -1,6 +0,0 @@
1
- import { Chart } from 'chart.js';
2
- import { ILineChartOptions } from '../line-chart.interface';
3
- export declare const customPointEllipsisPlugin: (options?: ILineChartOptions) => {
4
- id: string;
5
- afterDatasetsDraw: (chart: Chart<'line', number[], unknown>) => void;
6
- };