@oliasoft-open-source/charts-library 3.8.0-beta-2 → 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[];
@@ -544,20 +544,13 @@ export namespace PointEllipsisAnnotation {
544
544
  export namespace args_22 {
545
545
  export namespace chart_21 {
546
546
  export namespace data_11 {
547
- const datasets_11: ({
547
+ const datasets_11: {
548
548
  label: string;
549
549
  data: {
550
550
  x: number;
551
551
  y: number;
552
552
  }[];
553
- } | {
554
- showEllipsesAnnotation: boolean;
555
- label: string;
556
- data: {
557
- x: number;
558
- y: number;
559
- }[];
560
- })[];
553
+ }[];
561
554
  export { datasets_11 as datasets };
562
555
  }
563
556
  export { data_11 as data };
@@ -565,12 +558,6 @@ export namespace PointEllipsisAnnotation {
565
558
  export namespace annotations_1 {
566
559
  const showAnnotations_1: boolean;
567
560
  export { showAnnotations_1 as showAnnotations };
568
- export namespace pointEllipsisAnnotation {
569
- export { DEGTORAD as rotation };
570
- export const radiusX: number;
571
- export const radiusY: number;
572
- export const lineWidth: number;
573
- }
574
561
  }
575
562
  export { annotations_1 as annotations };
576
563
  }
@@ -1188,6 +1175,5 @@ export namespace Tension {
1188
1175
  }
1189
1176
  import { LineChart } from './line-chart';
1190
1177
  declare namespace basicChart { }
1191
- import { DEGTORAD } from './plugins/plugin-constants';
1192
1178
  declare const customLegendContainerID: "custom-legend-container";
1193
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-2",
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
- };