@oliasoft-open-source/charts-library 3.8.0-beta-5 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/index.js +568 -569
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +2 -73
  4. package/dist/src/components/bar-chart/bar-chart.interface.d.ts +36 -10
  5. package/dist/src/components/bar-chart/{get-bar-chart-data-labels.d.ts → utils/get-bar-chart-data-labels.d.ts} +1 -4
  6. package/dist/src/components/bar-chart/utils/get-bar-chart-scales.d.ts +3 -0
  7. package/dist/src/components/bar-chart/{get-bar-chart-tooltips.d.ts → utils/get-bar-chart-tooltips.d.ts} +1 -1
  8. package/dist/src/components/bar-chart/utils/use-bar-chart-config.d.ts +24 -0
  9. package/dist/src/components/common/common.interface.d.ts +7 -3
  10. package/dist/src/components/common/helpers/chart-border-plugin.d.ts +10 -2
  11. package/dist/src/components/common/helpers/chart-consts.d.ts +3 -3
  12. package/dist/src/components/common/helpers/chart-utils.d.ts +10 -12
  13. package/dist/src/components/common/helpers/get-chart-annotation.d.ts +0 -5
  14. package/dist/src/components/common/helpers/get-draggableData.d.ts +13 -13
  15. package/dist/src/components/common/helpers/range/estimate-data-series-have-close-values.d.ts +2 -4
  16. package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +3 -1
  17. package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +3 -3
  18. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +11 -15
  19. package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +0 -7
  20. package/dist/src/components/line-chart/hooks/use-generated-labels.d.ts +4 -1
  21. package/dist/src/components/line-chart/hooks/use-legend-state.d.ts +6 -5
  22. package/dist/src/components/line-chart/legend/legend-interface.d.ts +2 -2
  23. package/dist/src/components/line-chart/line-chart.interface.d.ts +41 -6
  24. package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +2 -1
  25. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +5 -4
  26. package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.d.ts +2 -5
  27. package/dist/src/components/line-chart/utils/datalabels-alignment/datalabels-alignment.interface.d.ts +20 -0
  28. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts +3 -4
  29. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +9 -9
  30. package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +4 -4
  31. package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +4 -8
  32. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +6 -10
  33. package/dist/src/components/line-chart/utils/get-generated-labels.d.ts +2 -1
  34. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +3 -2
  35. package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +1 -6
  36. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +3 -5
  37. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +2 -9
  38. package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +53 -0
  39. package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +2 -42
  40. package/dist/src/components/pie-chart/pie-chart.interface.d.ts +10 -2
  41. package/dist/src/components/pie-chart/use-pie-chart-config.d.ts +41 -0
  42. package/package.json +2 -3
  43. package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +0 -5
  44. package/dist/src/components/line-chart/controls/legend-options.d.ts +0 -1
@@ -1,73 +1,2 @@
1
- import { IBarChartProps } from './bar-chart.interface';
2
- import { AlignOptions, Position } from '../common/helpers/enums';
3
- export declare const getDefaultProps: (props: IBarChartProps) => {
4
- testId: string;
5
- data: {
6
- labels: string[];
7
- datasets: import("./bar-chart.interface").IBarChartDataset[];
8
- };
9
- options: {
10
- title: string | string[];
11
- direction: "vertical" | "horizontal";
12
- axes: {
13
- x: [{}] | import("../common/common.interface").ICommonAxis<"bottom" | "top">[];
14
- y: [{}] | import("../common/common.interface").ICommonAxis<"left" | "right">[];
15
- };
16
- additionalAxesOptions: {
17
- chartScaleType: "linear" | "logarithmic";
18
- reverse: boolean;
19
- stacked: boolean;
20
- beginAtZero: boolean;
21
- stepSize: number | undefined;
22
- suggestedMin: number | undefined;
23
- suggestedMax: number | undefined;
24
- min: number | undefined;
25
- max: number | undefined;
26
- };
27
- chartStyling: {
28
- width: string | number | undefined;
29
- height: string | number | undefined;
30
- maintainAspectRatio: boolean;
31
- staticChartHeight: boolean;
32
- performanceMode: boolean;
33
- };
34
- tooltip: {
35
- tooltips: boolean;
36
- showLabelsInTooltips: boolean;
37
- };
38
- graph: {
39
- showDataLabels: boolean;
40
- showMinorGridlines: boolean;
41
- };
42
- annotations: {
43
- showAnnotations: boolean;
44
- controlAnnotation: boolean;
45
- annotationsData: import("../common/common.interface").ICommonAnnotationsData[];
46
- };
47
- legend: {
48
- display: boolean;
49
- position: Position;
50
- align: AlignOptions;
51
- customLegend: import("../common/common.interface").ICommonCustomLegend<any>;
52
- };
53
- chartOptions: {
54
- enableZoom: boolean;
55
- enablePan: boolean;
56
- };
57
- interactions: {
58
- onLegendClick: ((text: string, hidden: boolean) => void) | undefined;
59
- onHover: ((event?: import("chart.js").ChartEvent | undefined, datasetIndex?: number | undefined, index?: number | undefined, generatedDataset?: any[] | undefined) => void) | undefined;
60
- onUnhover: ((event?: import("chart.js").ChartEvent | undefined, datasetIndex?: number | undefined, index?: number | undefined, generatedDataset?: any[] | undefined) => void) | undefined;
61
- };
62
- dragData: {
63
- enableDragData: boolean;
64
- showTooltip: boolean;
65
- roundPoints: boolean;
66
- dragX: boolean;
67
- dragY: boolean;
68
- onDragStart: (() => void) | undefined;
69
- onDrag: (() => void) | undefined;
70
- onDragEnd: (() => void) | undefined;
71
- };
72
- };
73
- };
1
+ import { IBarChartProps, IBarDefaultProps } from './bar-chart.interface';
2
+ export declare const getDefaultProps: (props: IBarChartProps) => IBarDefaultProps;
@@ -1,4 +1,5 @@
1
- import { ICommonAdditionalAxesOptions, ICommonAnnotations, ICommonAxis, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDragData, ICommonGraph, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling } from '../common/common.interface';
1
+ import { ICommonAdditionalAxesOptions, ICommonAnnotations, ICommonAnnotationsData, ICommonAxis, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDragData, ICommonGraph, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip } from '../common/common.interface';
2
+ import { IChartGraph } from '../common/helpers/chart-utils';
2
3
  export interface IBarStyling extends ICommonStyling {
3
4
  squareAspectRatio?: boolean;
4
5
  layoutPadding?: string | number | {
@@ -12,9 +13,9 @@ export interface IBarLegend extends ICommonLegend {
12
13
  customLegend?: ICommonCustomLegend<any>;
13
14
  }
14
15
  export interface IBarAxes {
15
- x: ICommonAxis<'top' | 'bottom'>[] | [{}];
16
- y: ICommonAxis<'left' | 'right'>[] | [{}];
17
- [key: string]: ICommonAxis<any>[] | [{}];
16
+ x: ICommonAxis<'top' | 'bottom'>[];
17
+ y: ICommonAxis<'left' | 'right'>[];
18
+ [key: string]: ICommonAxis[];
18
19
  }
19
20
  export interface IBarOptions extends ICommonOptions {
20
21
  direction: 'vertical' | 'horizontal';
@@ -30,21 +31,46 @@ export interface IBarOptions extends ICommonOptions {
30
31
  export interface IBarChartDataset extends ICommonDataset {
31
32
  isAnnotation?: boolean;
32
33
  annotationIndex?: number;
33
- borderSkipped?: any;
34
+ borderSkipped?: boolean;
34
35
  borderRadius?: number;
35
36
  xAxisID?: string;
36
37
  yAxisID?: string;
37
38
  hidden?: boolean;
38
- displayGroup?: any;
39
+ displayGroup?: string | number;
39
40
  type?: 'bar';
40
41
  }
42
+ export interface IBarChartBaseData {
43
+ labels: string[];
44
+ datasets: IBarChartDataset[];
45
+ }
41
46
  export interface IBarChartData extends ICommonData {
42
- data: {
43
- labels: string[];
44
- datasets: IBarChartDataset[];
45
- };
47
+ testId?: string;
48
+ data: IBarChartBaseData;
46
49
  options: IBarOptions;
47
50
  }
48
51
  export interface IBarChartProps {
49
52
  chart: IBarChartData;
50
53
  }
54
+ export interface IBarDefaultProps {
55
+ testId: string;
56
+ data: IBarChartBaseData;
57
+ options: {
58
+ title?: string | string[];
59
+ direction: 'vertical' | 'horizontal';
60
+ axes: IBarAxes;
61
+ additionalAxesOptions: ICommonAdditionalAxesOptions;
62
+ chartStyling: IBarStyling;
63
+ tooltip: ICommonTooltip;
64
+ graph: IChartGraph;
65
+ scales?: ICommonScales;
66
+ annotations: {
67
+ showAnnotations: boolean;
68
+ controlAnnotation: boolean;
69
+ annotationsData: ICommonAnnotationsData[];
70
+ };
71
+ legend: IBarLegend;
72
+ chartOptions: ICommonChartOptions;
73
+ interactions: ICommonInteractions;
74
+ dragData: ICommonDragData;
75
+ };
76
+ }
@@ -1,13 +1,10 @@
1
- import { IBarOptions } from './bar-chart.interface';
1
+ import { IBarOptions } from '../bar-chart.interface.ts';
2
2
  type ExtendedDisplayOptions = 'auto' | boolean;
3
3
  interface IExtendedDataLabelsOptions {
4
4
  display: ExtendedDisplayOptions;
5
5
  }
6
6
  /**
7
7
  * Returns the data labels configuration for a bar chart.
8
- *
9
- * @param {IBarChartOptions} options - The options for the bar chart.
10
- * @returns {Object} The data labels configuration for the chart.
11
8
  */
12
9
  declare const getBarChartDataLabels: (options: IBarOptions) => IExtendedDataLabelsOptions;
13
10
  export default getBarChartDataLabels;
@@ -0,0 +1,3 @@
1
+ import { IBarDefaultProps } from '../bar-chart.interface.ts';
2
+ declare const getBarChartScales: (chart: IBarDefaultProps) => any;
3
+ export default getBarChartScales;
@@ -1,4 +1,4 @@
1
- import { IBarOptions } from './bar-chart.interface';
1
+ import { IBarOptions } from '../bar-chart.interface.ts';
2
2
  /**
3
3
  * @param {IBarOptions} options - bar chart options object
4
4
  */
@@ -0,0 +1,24 @@
1
+ import { MutableRefObject } from 'react';
2
+ import { ActiveElement, Chart, ChartDataset, ChartEvent, LegendItem } from 'chart.js';
3
+ import { IBarChartDataset, IBarDefaultProps, IBarOptions } from '../bar-chart.interface';
4
+ import { ICommonDataValue, ICommonHoveredItems } from '../../common/common.interface';
5
+ export interface IGenerateBarChartDatasetsProps {
6
+ datasets: IBarChartDataset[];
7
+ options: IBarOptions;
8
+ }
9
+ export interface IGenerateBarChartDatasets extends ChartDataset<'bar', ICommonDataValue[]> {
10
+ borderWidth: number;
11
+ borderColor: string | string[];
12
+ backgroundColor: string | string[];
13
+ }
14
+ export interface IUseBarChartConfigProps {
15
+ chart: IBarDefaultProps;
16
+ chartRef: MutableRefObject<Chart | null>;
17
+ }
18
+ export declare const useBarChartConfig: ({ chart, chartRef, }: IUseBarChartConfigProps) => {
19
+ generatedDatasets: IGenerateBarChartDatasets[];
20
+ legendClick: (_e: ChartEvent, legendItem: LegendItem) => void;
21
+ onClick: (_evt: ChartEvent, _elements: ActiveElement[], chartInstance: Chart) => void;
22
+ onHover: (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
23
+ visibleAnnotationsIndexes: number[];
24
+ };
@@ -8,7 +8,7 @@ export interface ICommonDataValue {
8
8
  }
9
9
  export interface ICommonDataset {
10
10
  label?: string;
11
- borderColor?: string;
11
+ borderColor?: string | string[];
12
12
  backgroundColor?: string | string[];
13
13
  borderWidth?: number;
14
14
  data: ICommonDataValue[];
@@ -132,9 +132,13 @@ export interface ICommonChartPlugins {
132
132
  text: string;
133
133
  };
134
134
  }
135
- export interface ICommonAxis<PositionType> {
135
+ export interface ICommonAxis<PositionType = any> {
136
136
  label: string;
137
137
  position: PositionType;
138
138
  color: string | string[];
139
- unit: string;
139
+ unit?: string;
140
+ gridLines?: boolean;
141
+ stepSize?: number;
140
142
  }
143
+ export type UnusedParameter = unknown | any;
144
+ export type TPrimitive = string | number | boolean | null;
@@ -1,8 +1,16 @@
1
- import { Plugin } from 'chart.js';
1
+ import { Chart } from 'chart.js';
2
+ import { UnusedParameter } from '../common.interface';
3
+ interface IChartAreaBorderPluginOptions {
4
+ borderColor: string;
5
+ borderWidth: number;
6
+ borderDash: number[];
7
+ borderDashOffset?: number;
8
+ }
2
9
  /**
3
10
  * Chart border plugin config
4
11
  */
5
12
  export declare const chartAreaBorderPlugin: {
6
13
  id: string;
7
- beforeDraw(chart: any, _args: Plugin, options: any): void;
14
+ beforeDraw(chart: Chart, _: UnusedParameter, options: IChartAreaBorderPluginOptions): void;
8
15
  };
16
+ export {};
@@ -4,9 +4,9 @@ export declare const BORDER_WIDTH: {
4
4
  };
5
5
  export declare const BORDER_COLOR = "rgba(0,0,0,0.1)";
6
6
  export declare const ANNOTATION_DASH: number[];
7
- export declare const DEFAULT_FONT_SIZE = 12;
8
- export declare const DEFAULT_FONT_FAMILY = "\"Roobert\", \"Noto Sans\", sans-serif";
9
- export declare const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
7
+ export declare const DEFAULT_FONT_SIZE = 13;
8
+ export declare const DEFAULT_FONT_FAMILY = "\"Lato\", sans-serif";
9
+ export declare const DEFAULT_COLOR = "rgba(0,0,0,.87)";
10
10
  export declare const LEGEND_LABEL_BOX_SIZE = 12;
11
11
  export declare const TOOLTIP_PADDING = 8;
12
12
  export declare const TOOLTIP_BOX_PADDING = 4;
@@ -1,7 +1,7 @@
1
- import { ChartTypeRegistry, Plugin } from 'chart.js';
2
- import { ICommonAnnotationsData, ICommonCustomLegend } from '../common.interface';
1
+ import { ChartTypeRegistry, LegendItem, Plugin } from 'chart.js';
2
+ import { ICommonAnnotationsData, ICommonCustomLegend, UnusedParameter } from '../common.interface';
3
3
  import { Position } from './enums';
4
- interface IChartGraph {
4
+ export interface IChartGraph {
5
5
  showMinorGridlines: boolean;
6
6
  }
7
7
  interface IOptions {
@@ -22,7 +22,7 @@ interface IStyling {
22
22
  performanceMode?: boolean;
23
23
  }
24
24
  interface IAxis {
25
- label: string;
25
+ label?: string;
26
26
  }
27
27
  interface ILegend {
28
28
  customLegend?: ICommonCustomLegend<any>;
@@ -56,10 +56,8 @@ export declare const getTitle: (options: IOptions) => {
56
56
  };
57
57
  /**
58
58
  * @function isVertical
59
- * @param {'vertical'|'horizontal'|string} direction
60
- * @return {boolean} returns true if chart direction is vertical
61
59
  */
62
- export declare const isVertical: (direction: string) => boolean;
60
+ export declare const isVertical: (direction: 'vertical' | 'horizontal') => boolean;
63
61
  /**
64
62
  * @param {'x'|'y'} axisType
65
63
  * @param {number} i - index
@@ -72,20 +70,20 @@ export declare const getAxisPosition: (axisType: string, i: number) => Position;
72
70
  * @return {string} - class name
73
71
  */
74
72
  export declare const getClassName: (chartStyling: IStyling, styles: Record<string, string>) => string;
75
- export declare const getLegend: (options: IOptions, clickHandler: (_e: any, legendItem: any) => void) => {
76
- position: Position;
73
+ export declare const getLegend: (options: IOptions, clickHandler: (_: UnusedParameter, legendItem: LegendItem) => void) => {
74
+ position: any;
77
75
  display: boolean | undefined;
78
- align: string | undefined;
76
+ align: "end" | "start" | "center";
79
77
  labels: {
80
78
  boxHeight: number;
81
79
  boxWidth: number | undefined;
82
80
  usePointStyle: boolean | undefined;
83
81
  };
84
- onClick: (_e: any, legendItem: any) => void;
82
+ onClick: (_: UnusedParameter, legendItem: LegendItem) => void;
85
83
  };
86
84
  export declare const afterLabelCallback: (tooltipItem: Record<string, any>) => string;
87
85
  export declare const getTooltipLabel: (tooltipItem: Record<string, any>, showLabelsInTooltips: boolean) => string;
88
86
  export declare const getChartFileName: (axes: IAxis[]) => string;
89
87
  export declare const setDefaultTheme: () => void;
90
- export declare const isNilOrEmpty: (value: any) => boolean;
88
+ export declare const isNilOrEmpty: <T>(value: T | null | undefined) => boolean;
91
89
  export {};
@@ -16,11 +16,6 @@ interface IOptions {
16
16
  interface IState {
17
17
  showAnnotationLineIndex?: number[];
18
18
  }
19
- /**
20
- * @param {ICommonChartOptions} options - chart options object
21
- * @param {IInitialState} state - chart state object controlled by useReducer or similar
22
- * @return {{annotations: []}}
23
- */
24
19
  declare const getAnnotation: (options: IOptions, state: IState) => {
25
20
  annotations: IAnnotationData | undefined;
26
21
  };
@@ -1,18 +1,18 @@
1
1
  import { ICommonOptions } from '../common.interface';
2
+ interface IDraggableDataOptions {
3
+ dragX: boolean;
4
+ dragY: boolean;
5
+ round: boolean;
6
+ showTooltip: boolean;
7
+ onDragStart: () => void;
8
+ onDrag: () => void;
9
+ onDragEnd: () => void;
10
+ }
11
+ interface IDraggableData {
12
+ dragData: IDraggableDataOptions;
13
+ }
2
14
  /**
3
15
  * @param {ICommonChartOptions} options - line chart options object
4
16
  */
5
- declare const getDraggableData: (options: ICommonOptions) => {
6
- dragData: {
7
- dragX: boolean | undefined;
8
- dragY: boolean | undefined;
9
- round: boolean | undefined;
10
- showTooltip: boolean | undefined;
11
- onDragStart: () => void;
12
- onDrag: () => void;
13
- onDragEnd: () => void;
14
- };
15
- } | {
16
- dragData?: undefined;
17
- };
17
+ declare const getDraggableData: (options: ICommonOptions) => IDraggableData | object;
18
18
  export default getDraggableData;
@@ -1,10 +1,8 @@
1
+ import { TGeneratedLineChartDatasets } from '../../../line-chart/line-chart.interface';
1
2
  /**
2
3
  * Estimates whether any of the data series has values that are all close together
3
4
  * - checks only the first and last values in each series (i.e. assumes they are ordered)
4
5
  * - uses an equality check with tolerance for decimal precision noise
5
6
  * - this is just an inexpensive "guesstimate" (full min/max detection can be used afterwards)
6
- *
7
- * @param {Array} generatedDatasets chart dataset series with x, y points
8
- * @return {boolean} - at least one series has values that seem close together
9
7
  */
10
- export declare const estimateDataSeriesHaveCloseValues: (generatedDatasets: Array<any>) => boolean;
8
+ export declare const estimateDataSeriesHaveCloseValues: (generatedDatasets: TGeneratedLineChartDatasets) => boolean;
@@ -13,7 +13,9 @@ export interface IAxesOptions {
13
13
  initialAxesRanges: IInitAxisRange[];
14
14
  axes: IAxisState[];
15
15
  controlsAxesLabels: IAxisControlLabel[];
16
- onUpdateAxes: (axes: IAxisState) => void;
16
+ onUpdateAxes: ({ axes }: {
17
+ axes: IAxisState;
18
+ }) => void;
17
19
  onResetAxes: () => void;
18
20
  depthType?: IDepthType | object;
19
21
  close?: () => void;
@@ -1,16 +1,16 @@
1
1
  import { Dispatch, ReactNode, RefObject } from 'react';
2
2
  import { Chart } from 'chart.js';
3
- import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
3
+ import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
4
4
  import { IState } from '../state/state.interfaces';
5
5
  export interface IControls {
6
6
  headerComponent?: ReactNode;
7
7
  subheaderComponent?: Element;
8
- table?: Element;
8
+ table?: ReactNode;
9
9
  chartRef: RefObject<Chart>;
10
10
  state: IState;
11
11
  options: ILineChartOptions;
12
12
  dispatch: Dispatch<any>;
13
- generatedDatasets: ILineChartDataset[];
13
+ generatedDatasets: TGeneratedLineChartDatasets;
14
14
  translations: Record<string, string>;
15
15
  controlsPortalId?: string;
16
16
  }
@@ -1,36 +1,32 @@
1
- import { Dispatch, RefObject } from 'react';
1
+ import { Dispatch, KeyboardEvent, RefObject, SetStateAction } from 'react';
2
2
  import { Chart, ChartEvent } from 'chart.js';
3
- import { ICommonHoveredItems } from '../../common/common.interface';
4
- import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
5
- import { InitialState, IState } from '../state/state.interfaces';
3
+ import { ICommonDataValue, ICommonHoveredItems } from '../../common/common.interface';
4
+ import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
5
+ import { IAxisState, IState } from '../state/state.interfaces';
6
6
  interface IUseChartFunctions {
7
7
  chartRef: RefObject<Chart>;
8
8
  state: IState;
9
9
  options: ILineChartOptions;
10
10
  dispatch: Dispatch<any>;
11
- generatedDatasets: ILineChartDataset[];
11
+ generatedDatasets: TGeneratedLineChartDatasets;
12
12
  }
13
13
  /**
14
14
  * Custom hook that encapsulates the chart-related functions and their dependencies
15
- * @param {Object} chartRef - Chart reference
16
- * @param {Object} state - The component state
17
- * @param {Object} options - Chart options
18
- * @param {Function} dispatch - Dispatch function from useReducer
19
- * @param {Array} generatedDatasets - Chart datasets
20
- * @returns {Object} An object containing the chart-related functions
21
15
  */
22
16
  export declare const useChartFunctions: ({ chartRef, state, options, dispatch, generatedDatasets, }: IUseChartFunctions) => {
23
17
  resetZoom: () => void;
24
- onHover: (hoveredPoint: any, setHoveredPoint: any) => (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
18
+ onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null>>) => (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
25
19
  handleDownload: () => void;
26
- handleKeyDown: (evt: any) => void;
27
- handleKeyUp: (evt: any) => void;
20
+ handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
21
+ handleKeyUp: (event: KeyboardEvent<HTMLDivElement>) => void;
28
22
  controlsAxesLabels: {
29
23
  id: string;
30
24
  label: string;
31
25
  }[];
32
26
  updateAxesRangesFromChart: () => void;
33
27
  onResetAxes: () => void;
34
- onUpdateAxes: ({ axes }: InitialState) => void;
28
+ onUpdateAxes: ({ axes }: {
29
+ axes: IAxisState;
30
+ }) => void;
35
31
  };
36
32
  export {};
@@ -12,13 +12,6 @@ interface IUseChartState {
12
12
  }
13
13
  /**
14
14
  * Hook for managing the state of the chart.
15
- *
16
- * @param chartRef - The reference to the chart.
17
- * @param options - The chart options.
18
- * @param state - The chart state.
19
- * @param dispatch - The dispatch function for state management.
20
- * @param persistenceId - The chart persistenceId.
21
- * @param {ILineChartDataset[]} generatedDatasets - An array of generated datasets for the chart.
22
15
  */
23
16
  export declare const useChartState: ({ chartRef, options, state, dispatch, persistenceId, generatedDatasets, }: IUseChartState) => void;
24
17
  export {};
@@ -1 +1,4 @@
1
- export declare const useGeneratedLabels: (chartRef: any, generatedDatasets: Record<string, any>[]) => any[];
1
+ import { RefObject } from 'react';
2
+ import { Chart } from 'chart.js';
3
+ import { TGeneratedLineChartDatasets } from '../line-chart.interface';
4
+ export declare const useGeneratedLabels: (chartRef: RefObject<Chart>, generatedDatasets: TGeneratedLineChartDatasets) => any[];
@@ -1,5 +1,6 @@
1
1
  import { Dispatch, RefObject } from 'react';
2
- import { Chart, ChartEvent } from 'chart.js';
2
+ import { Chart, LegendItem } from 'chart.js';
3
+ import { UnusedParameter } from '../../common/common.interface';
3
4
  import { ILineChartOptions } from '../line-chart.interface';
4
5
  import { IState } from '../state/state.interfaces';
5
6
  export interface IUseLegendStateProps {
@@ -17,18 +18,18 @@ export type THiddenState = {
17
18
  * Custom hook to manage legend state.
18
19
  */
19
20
  export declare const useLegendState: ({ chartRef, options, state, dispatch, }: IUseLegendStateProps) => {
20
- legendClick: (_e: ChartEvent, legendItem: any) => void;
21
+ legendClick: (_: UnusedParameter, legendItem: LegendItem) => void;
21
22
  hiddenStates: THiddenState[];
22
23
  legend: {
23
- position: import("../../common/helpers/enums").Position;
24
+ position: any;
24
25
  display: boolean | undefined;
25
- align: string | undefined;
26
+ align: "end" | "start" | "center";
26
27
  labels: {
27
28
  boxHeight: number;
28
29
  boxWidth: number | undefined;
29
30
  usePointStyle: boolean | undefined;
30
31
  };
31
- onClick: (_e: any, legendItem: any) => void;
32
+ onClick: (_: any, legendItem: LegendItem) => void;
32
33
  };
33
34
  customLegendPlugin: {
34
35
  htmlLegend: {
@@ -1,7 +1,7 @@
1
1
  import { Dispatch, MouseEventHandler, RefObject } from 'react';
2
2
  import { Chart, ChartArea } from 'chart.js';
3
3
  import { IState } from '../state/state.interfaces';
4
- import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
4
+ import { ILineChartDataset, ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
5
5
  import { Position } from '../../common/helpers/enums';
6
6
  export interface ILegendDropZone {
7
7
  position: Position;
@@ -30,7 +30,7 @@ export interface ILegend {
30
30
  state: IState;
31
31
  options: ILineChartOptions;
32
32
  dispatch: Dispatch<any>;
33
- generatedDatasets: ILineChartDataset[];
33
+ generatedDatasets: TGeneratedLineChartDatasets;
34
34
  translations?: Record<string, string>;
35
35
  }
36
36
  export interface ILegendPanel extends ILegend {
@@ -1,4 +1,5 @@
1
- import { ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip } from '../common/common.interface';
1
+ import { ReactNode } from 'react';
2
+ import { ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDataValue, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip } from '../common/common.interface';
2
3
  export interface ILChartOptions extends ICommonChartOptions {
3
4
  showPoints: boolean;
4
5
  closeOnOutsideClick: boolean;
@@ -35,16 +36,19 @@ export interface IUnitOptions {
35
36
  selectedUnit: string;
36
37
  setSelectedUnit: () => void;
37
38
  }
38
- export interface ILineChartAxis<PositionType> {
39
+ export interface ILineChartAxis<PositionType = any> {
40
+ id?: string;
39
41
  label: string;
40
42
  position: PositionType;
41
43
  color: string | string[];
42
44
  unit?: IUnitOptions;
45
+ stepSize?: number;
46
+ gridLines?: ILineChartGraph;
43
47
  }
44
48
  export interface ILineChartAxes {
45
49
  x: ILineChartAxis<'top' | 'bottom'>[];
46
50
  y: ILineChartAxis<'left' | 'right'>[];
47
- [key: string]: ILineChartAxis<any>[];
51
+ [key: string]: ILineChartAxis[];
48
52
  }
49
53
  export interface IDepthType {
50
54
  options: string[];
@@ -53,7 +57,7 @@ export interface IDepthType {
53
57
  }
54
58
  export interface ILineChartStyling extends ICommonStyling {
55
59
  squareAspectRatio?: number | boolean;
56
- layoutPadding?: string | number | {
60
+ layoutPadding?: number | {
57
61
  top: number;
58
62
  bottom: number;
59
63
  left: number;
@@ -89,9 +93,10 @@ export interface ILineChartDataset extends ICommonDataset {
89
93
  pointHoverRadius?: number;
90
94
  pointHitRadius?: number;
91
95
  fill?: boolean;
96
+ xAxisID?: string;
92
97
  yAxisID?: string;
93
98
  formation?: boolean;
94
- displayGroup?: any;
99
+ displayGroup?: boolean;
95
100
  pointStyle?: string;
96
101
  }
97
102
  export interface ILineChartData extends ICommonData {
@@ -104,5 +109,35 @@ export interface ILineChartData extends ICommonData {
104
109
  }
105
110
  export interface ILineChartProps {
106
111
  chart: ILineChartData;
107
- table?: any;
112
+ table?: ReactNode;
113
+ }
114
+ export interface IGeneratedLineChartDataset {
115
+ label?: string;
116
+ data: ICommonDataValue[];
117
+ showLine?: boolean;
118
+ lineTension: number;
119
+ spanGaps: boolean;
120
+ borderWidth: number;
121
+ borderDash: number[];
122
+ borderJoinStyle: 'round' | 'bevel' | 'miter';
123
+ borderColor: string;
124
+ backgroundColor: string | string[];
125
+ pointBackgroundColor: string;
126
+ pointRadius: number;
127
+ pointHoverRadius: number;
128
+ pointHitRadius: number;
129
+ isAnnotation?: boolean;
130
+ annotationType?: string;
131
+ annotationIndex?: number;
132
+ annotationLabel?: string;
133
+ annotationBackgroundColor?: string;
134
+ annotationPointBackgroundColor?: string;
135
+ annotationBorderColor?: string;
136
+ annotationBorderDash?: number[];
137
+ annotationBorderWidth?: number;
138
+ displayGroup?: boolean;
139
+ hideLegend?: boolean;
140
+ xAxisID?: string;
141
+ yAxisID?: string;
108
142
  }
143
+ export type TGeneratedLineChartDatasets = IGeneratedLineChartDataset[];
@@ -1 +1,2 @@
1
- export declare const formatAxisLabelNumbers: (tickValue: number, ticks: Array<any>) => string;
1
+ import { Tick } from 'chart.js';
2
+ export declare const formatAxisLabelNumbers: (tickValue: string | number, ticks: Tick[]) => string;
@@ -1,10 +1,11 @@
1
+ import { RefObject } from 'react';
2
+ import { Chart } from 'chart.js';
3
+ import { ILineChartOptions, TGeneratedLineChartDatasets } from '../../line-chart.interface';
4
+ import { IState } from '../../state/state.interfaces';
1
5
  /**
2
6
  * Auto scales axis ranges (mix, max) if no explicit range is set
3
7
  * - overrides some edge cases not handled well by default chart.js
4
8
  * - supports optional padding when `autoAxisPadding` is set
5
9
  * - otherwise does not set min/max (falls back to chart.js default)
6
- *
7
- * @function autoScale
8
- * @return {object} scales
9
10
  */
10
- export declare const autoScale: (options: any, state: any, generatedDatasets: any, chartRef: any) => any;
11
+ export declare const autoScale: (options: ILineChartOptions, state: IState, generatedDatasets: TGeneratedLineChartDatasets, chartRef: RefObject<Chart>) => {};