@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.
Files changed (125) hide show
  1. package/dist/index.d.ts +15 -1217
  2. package/dist/index.js +453 -68
  3. package/dist/src/components/bar-chart/bar-chart-const.d.ts +2 -0
  4. package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +3 -0
  5. package/dist/src/components/bar-chart/bar-chart.d.ts +3 -0
  6. package/dist/src/components/bar-chart/bar-chart.interface.d.ts +141 -0
  7. package/dist/src/components/bar-chart/utils/get-bar-chart-data-labels.d.ts +10 -0
  8. package/dist/src/components/bar-chart/utils/get-bar-chart-scales.d.ts +3 -0
  9. package/dist/src/components/bar-chart/utils/get-bar-chart-tooltips.d.ts +6 -0
  10. package/dist/src/components/bar-chart/utils/use-bar-chart-config.d.ts +13 -0
  11. package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +55 -0
  12. package/dist/src/components/common/common.interface.d.ts +275 -0
  13. package/dist/src/components/common/controls-portal.d.ts +7 -0
  14. package/dist/src/components/common/enums.d.ts +87 -0
  15. package/dist/src/components/common/helpers/add-transparency/add-transparency.d.ts +1 -0
  16. package/dist/src/components/common/helpers/callout-helpers/callout-helpers.d.ts +25 -0
  17. package/dist/src/components/common/helpers/chart-border-plugin.d.ts +16 -0
  18. package/dist/src/components/common/helpers/chart-consts.d.ts +39 -0
  19. package/dist/src/components/common/helpers/chart-utils.d.ts +86 -0
  20. package/dist/src/components/common/helpers/container.d.ts +18 -0
  21. package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -0
  22. package/dist/src/components/common/helpers/download-pgn.d.ts +3 -0
  23. package/dist/src/components/common/helpers/get-chart-annotation.d.ts +139 -0
  24. package/dist/src/components/common/helpers/get-chart-from-ctx.d.ts +1 -0
  25. package/dist/src/components/common/helpers/get-custom-legend-plugin-example.d.ts +8 -0
  26. package/dist/src/components/common/helpers/get-draggableData.d.ts +18 -0
  27. package/dist/src/components/common/helpers/get-grouped-color-scheme/get-grouped-color-scheme.d.ts +1 -0
  28. package/dist/src/components/common/helpers/input-normalizers.d.ts +15 -0
  29. package/dist/src/components/common/helpers/range/estimate-data-series-have-close-values.d.ts +8 -0
  30. package/dist/src/components/common/helpers/range/range.d.ts +33 -0
  31. package/dist/src/components/common/helpers/text.d.ts +1 -0
  32. package/dist/src/components/common/helpers/to-annotation.d.ts +4 -0
  33. package/dist/src/components/common/hooks/use-generated-labels.d.ts +4 -0
  34. package/dist/src/components/common/hooks/use-legend-state.d.ts +28 -0
  35. package/dist/src/components/common/hooks/use-legend.d.ts +4 -0
  36. package/dist/src/components/common/hooks/use-update-annotations.d.ts +4 -0
  37. package/dist/src/components/common/legend-component/legend-dropzone.d.ts +3 -0
  38. package/dist/src/components/common/legend-component/legend-interface.d.ts +47 -0
  39. package/dist/src/components/common/legend-component/legend-item/LegendItemLine.d.ts +5 -0
  40. package/dist/src/components/common/legend-component/legend-item/legend-item.d.ts +3 -0
  41. package/dist/src/components/common/legend-component/legend-panel.d.ts +3 -0
  42. package/dist/src/components/common/legend-component/legend.d.ts +3 -0
  43. package/dist/src/components/common/legend-component/state/legend-action-types.d.ts +3 -0
  44. package/dist/src/components/common/legend-component/state/legend-context.d.ts +14 -0
  45. package/dist/src/components/common/legend-component/state/legend-state-reducer.d.ts +30 -0
  46. package/dist/src/components/common/legend-component/utils/create-style-object.d.ts +27 -0
  47. package/dist/src/components/common/legend-component/utils/get-generated-labels.d.ts +2 -0
  48. package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-dragger-plugin.d.ts +15 -0
  49. package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-position-storage.d.ts +7 -0
  50. package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +21 -0
  51. package/dist/src/components/common/plugins/annotation-dragger-plugin/event-helpers.d.ts +6 -0
  52. package/dist/src/components/common/plugins/annotation-dragger-plugin/helpers.d.ts +53 -0
  53. package/dist/src/components/common/plugins/annotation-dragger-plugin/point-annotation-label.d.ts +5 -0
  54. package/dist/src/components/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts +9 -0
  55. package/dist/src/components/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +18 -0
  56. package/dist/src/components/common/plugins/gradient-background-plugin/enums.d.ts +10 -0
  57. package/dist/src/components/common/plugins/gradient-background-plugin/gradient-background-plugin.d.ts +2 -0
  58. package/dist/src/components/line-chart/constants/default-translations.d.ts +25 -0
  59. package/dist/src/components/line-chart/constants/line-chart-consts.d.ts +13 -0
  60. package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +57 -0
  61. package/dist/src/components/line-chart/controls/axes-options/axes-options.d.ts +6 -0
  62. package/dist/src/components/line-chart/controls/axes-options/axes-validation.d.ts +8 -0
  63. package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +19 -0
  64. package/dist/src/components/line-chart/controls/controls.d.ts +3 -0
  65. package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +14 -0
  66. package/dist/src/components/line-chart/controls/drag-options.d.ts +23 -0
  67. package/dist/src/components/line-chart/controls/line-options.d.ts +19 -0
  68. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +32 -0
  69. package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +19 -0
  70. package/dist/src/components/line-chart/hooks/use-chart-plugins.d.ts +7 -0
  71. package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +12 -0
  72. package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +12 -0
  73. package/dist/src/components/line-chart/initialize/config.d.ts +12 -0
  74. package/dist/src/components/line-chart/initialize/initialize-line-chart.d.ts +12 -0
  75. package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +3 -0
  76. package/dist/src/components/line-chart/line-chart.d.ts +3 -0
  77. package/dist/src/components/line-chart/line-chart.interface.d.ts +236 -0
  78. package/dist/src/components/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
  79. package/dist/src/components/line-chart/plugins/callout-plugin/helpers.d.ts +42 -0
  80. package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +17 -0
  81. package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +8 -0
  82. package/dist/src/components/line-chart/plugins/line-markers-plugin/draw.d.ts +39 -0
  83. package/dist/src/components/line-chart/plugins/line-markers-plugin/line-markers-plugin.d.ts +10 -0
  84. package/dist/src/components/line-chart/plugins/line-markers-plugin/types.d.ts +109 -0
  85. package/dist/src/components/line-chart/plugins/line-markers-plugin/utils.d.ts +40 -0
  86. package/dist/src/components/line-chart/plugins/plugin-constants.d.ts +11 -0
  87. package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +9 -0
  88. package/dist/src/components/line-chart/state/action-types.d.ts +12 -0
  89. package/dist/src/components/line-chart/state/helpers.d.ts +13 -0
  90. package/dist/src/components/line-chart/state/initial-state.d.ts +11 -0
  91. package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +2 -0
  92. package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +15 -0
  93. package/dist/src/components/line-chart/state/state.interfaces.d.ts +26 -0
  94. package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +2 -0
  95. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +18 -0
  96. package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.d.ts +12 -0
  97. package/dist/src/components/line-chart/utils/datalabels-alignment/datalabels-alignment.interface.d.ts +20 -0
  98. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts +8 -0
  99. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +11 -0
  100. package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +6 -0
  101. package/dist/src/components/line-chart/utils/enums.d.ts +4 -0
  102. package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +8 -0
  103. package/dist/src/components/line-chart/utils/get-annotations-data.d.ts +1 -0
  104. package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +1 -0
  105. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +9 -0
  106. package/dist/src/components/line-chart/utils/get-axis-range-by-type.d.ts +10 -0
  107. package/dist/src/components/line-chart/utils/get-generated-labels.d.ts +2 -0
  108. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +16 -0
  109. package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +589 -0
  110. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +30 -0
  111. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +24 -0
  112. package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +8 -0
  113. package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +50 -0
  114. package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +3 -0
  115. package/dist/src/components/pie-chart/pie-chart.d.ts +3 -0
  116. package/dist/src/components/pie-chart/pie-chart.interface.d.ts +58 -0
  117. package/dist/src/components/pie-chart/use-pie-chart-config.d.ts +42 -0
  118. package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +239 -0
  119. package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +72 -0
  120. package/dist/src/components/scatter-chart/scatter-chart-get-default-props.d.ts +4 -0
  121. package/dist/src/components/scatter-chart/scatter-chart.d.ts +3 -0
  122. package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +111 -0
  123. package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +176 -0
  124. package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +21 -0
  125. package/package.json +9 -9
@@ -0,0 +1,39 @@
1
+ import { ICommonGradientColor } from '../common.interface';
2
+ export declare const BORDER_WIDTH: {
3
+ ZERO: number;
4
+ INITIAL: number;
5
+ HOVERED: number;
6
+ POINT_HOVERED: number;
7
+ };
8
+ export declare const BORDER_COLOR = "rgba(0,0,0,0.1)";
9
+ export declare const ANNOTATION_DASH: number[];
10
+ export declare const DEFAULT_FONT_SIZE = 12;
11
+ export declare const DEFAULT_FONT_FAMILY = "\"Roobert\", \"Noto Sans\", sans-serif";
12
+ export declare const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
13
+ export declare const LEGEND_LABEL_BOX_SIZE = 12;
14
+ export declare const TOOLTIP_PADDING = 8;
15
+ export declare const TOOLTIP_BOX_PADDING = 4;
16
+ export declare const TRANSPARENT = "transparent";
17
+ export declare const LOGARITHMIC_STEPS: number[];
18
+ export declare const COLORS: string[];
19
+ /**
20
+ * @type {string}
21
+ * @desc equivalent of 0.6 rgba alpha chanel
22
+ */
23
+ export declare const ALPHA_CHANEL = "99";
24
+ /**
25
+ * @type {number}
26
+ * @desc #FFFFFF as decimal number
27
+ */
28
+ export declare const WHITE_COLOR_AS_DECIMAL = 16777215;
29
+ export declare const AUTO = "auto";
30
+ export declare const ANIMATION_DURATION: {
31
+ NO: number;
32
+ SLOW: number;
33
+ FAST: number;
34
+ };
35
+ export declare const DEFAULT_CHART_NAME = "new_chart";
36
+ export declare const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
37
+ export declare const DECIMAL_POINT_TOLERANCE = 9;
38
+ export declare const MAX_DECIMAL_DIFF: number;
39
+ export declare const GRADIENT_COLORS: ICommonGradientColor[];
@@ -0,0 +1,86 @@
1
+ import { ChartTypeRegistry, LegendItem, Plugin } from 'chart.js';
2
+ import { ICommonCustomLegend, UnusedParameter } from '../common.interface';
3
+ import { Position } from '../enums';
4
+ export interface IChartGraph {
5
+ showMinorGridlines?: boolean;
6
+ }
7
+ interface IOptions {
8
+ title?: string | string[];
9
+ legend?: {
10
+ position?: Position;
11
+ display?: boolean;
12
+ align?: string;
13
+ usePointStyle?: boolean;
14
+ };
15
+ }
16
+ interface IStyling {
17
+ width?: string | number;
18
+ height?: string | number;
19
+ squareAspectRatio?: number | boolean;
20
+ maintainAspectRatio?: boolean;
21
+ staticChartHeight?: boolean;
22
+ performanceMode?: boolean;
23
+ }
24
+ interface IAxis {
25
+ label?: string;
26
+ }
27
+ interface ILegend {
28
+ customLegend?: ICommonCustomLegend<any>;
29
+ }
30
+ /**
31
+ * @param { graph } graph - graph data from chart options
32
+ * @param { legend } legend
33
+ * @return {[]}
34
+ */
35
+ export declare const getPlugins: <T extends keyof ChartTypeRegistry>(graph: IChartGraph | undefined, legend: ILegend) => Plugin<T>[] | any;
36
+ /**
37
+ * @param {string[]} colors - color schema
38
+ * @return {string} - random color
39
+ */
40
+ export declare const generateRandomColor: (colors: string[]) => string[];
41
+ /**
42
+ * @param {ICommonChartOptions} options - chart options object
43
+ * @return {{color: (string|undefined), display: boolean, text}|{}}
44
+ */
45
+ export declare const getTitle: (options: IOptions) => {
46
+ display: boolean;
47
+ text: string | string[];
48
+ } | {
49
+ display?: undefined;
50
+ text?: undefined;
51
+ };
52
+ /**
53
+ * @function isVertical
54
+ */
55
+ export declare const isVertical: (direction: "vertical" | "horizontal") => direction is "vertical";
56
+ /**
57
+ * @param {'x'|'y'} axisType
58
+ * @param {number} i - index
59
+ * @return {'top'|'bottom'|'left'|'right'|*}
60
+ */
61
+ export declare const getAxisPosition: (axisType: string, i: number) => Position;
62
+ /**
63
+ * @param {chartStyling} chartStyling
64
+ * @param {Object} styles - styles imported form .less file
65
+ * @return {string} - class name
66
+ */
67
+ export declare const getClassName: (chartStyling: IStyling, styles: Record<string, string>) => string;
68
+ export declare const getLegend: (options: IOptions, clickHandler: (_: UnusedParameter, legendItem: LegendItem) => void) => {
69
+ position: any;
70
+ display: boolean | undefined;
71
+ align: "center" | "start" | "end";
72
+ labels: {
73
+ boxHeight: number;
74
+ boxWidth: number | undefined;
75
+ usePointStyle: boolean | undefined;
76
+ };
77
+ onClick: (_: UnusedParameter, legendItem: LegendItem) => void;
78
+ };
79
+ export declare const afterLabelCallback: (tooltipItem: Record<string, any>) => string;
80
+ export declare const getTooltipLabel: (tooltipItem: Record<string, any>, showLabelsInTooltips: boolean) => string;
81
+ export declare const sanitize: (str: string) => string;
82
+ export declare const getChartFileName: (axes?: IAxis[]) => string;
83
+ export declare const setDefaultTheme: () => void;
84
+ export declare const isNilOrEmpty: <T>(value: T | null | undefined) => boolean;
85
+ export declare const isEmptyString: (value: string) => value is "";
86
+ export {};
@@ -0,0 +1,18 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ interface ContainerProps {
3
+ style?: CSSProperties;
4
+ children: ReactNode;
5
+ margin?: boolean;
6
+ deprecatedMessage?: string;
7
+ warningMessage?: string;
8
+ }
9
+ export declare const Container: {
10
+ ({ style, children, margin, deprecatedMessage, warningMessage, }: ContainerProps): import("react/jsx-runtime").JSX.Element;
11
+ defaultProps: {
12
+ style: {};
13
+ margin: boolean;
14
+ deprecatedMessage: null;
15
+ warningMessage: null;
16
+ };
17
+ };
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare const customFormatNumber: (labelNumber: number, scientificNotation: boolean) => string;
@@ -0,0 +1,3 @@
1
+ import { RefObject } from 'react';
2
+ import { Chart } from 'chart.js';
3
+ export declare const downloadPgn: (chartRef: RefObject<Chart>) => void;
@@ -0,0 +1,139 @@
1
+ import { Chart } from 'chart.js';
2
+ import { AnnotationType } from '../plugins/annotation-dragger-plugin/enums';
3
+ import { Position } from '../enums';
4
+ import { ICommonAnnotationElement, ICommonAnnotationsData, ICoordinates } from '../common.interface';
5
+ export interface IGetAnnotationsProps {
6
+ showAnnotations: boolean;
7
+ annotationsData: ICommonAnnotationsData[];
8
+ }
9
+ interface TChart extends Chart {
10
+ hoveredAnnotationId?: string | null;
11
+ }
12
+ export declare const generateAnn: (ann: ICommonAnnotationsData, index: number) => {
13
+ display: boolean | undefined;
14
+ annotationIndex: number;
15
+ id: string;
16
+ scaleID: "x" | "y" | undefined;
17
+ label: {
18
+ backgroundColor: string;
19
+ content: string | undefined;
20
+ display: boolean;
21
+ position: Position;
22
+ color?: undefined;
23
+ font?: undefined;
24
+ borderWidth?: undefined;
25
+ padding?: undefined;
26
+ borderRadius?: undefined;
27
+ borderColor?: undefined;
28
+ } | {
29
+ backgroundColor: string;
30
+ content: string | undefined;
31
+ display: boolean;
32
+ position: string;
33
+ color: string;
34
+ font: string;
35
+ borderWidth: number;
36
+ padding: number;
37
+ borderRadius: number;
38
+ borderColor: string;
39
+ } | {
40
+ position: {
41
+ x: string;
42
+ y: string;
43
+ } | undefined;
44
+ content: string | undefined;
45
+ backgroundColor?: string;
46
+ display: boolean;
47
+ color?: string;
48
+ font: string | {
49
+ weight: string;
50
+ };
51
+ borderColor?: string;
52
+ callout?: Record<string, unknown>;
53
+ borderWidth?: undefined;
54
+ padding?: undefined;
55
+ borderRadius?: undefined;
56
+ } | {
57
+ position: {
58
+ x: string;
59
+ y: string;
60
+ } | undefined;
61
+ content: string | undefined;
62
+ backgroundColor?: string;
63
+ display: boolean;
64
+ color?: string;
65
+ font: string | {
66
+ weight: string;
67
+ };
68
+ borderColor?: string;
69
+ callout?: Record<string, unknown>;
70
+ borderWidth?: undefined;
71
+ padding?: undefined;
72
+ borderRadius?: undefined;
73
+ } | {
74
+ position: {
75
+ x: string;
76
+ y: string;
77
+ } | undefined;
78
+ content: string | undefined;
79
+ backgroundColor?: string;
80
+ display: boolean;
81
+ color?: string;
82
+ font: string | {
83
+ weight: string;
84
+ };
85
+ borderColor?: string;
86
+ callout?: Record<string, unknown>;
87
+ borderWidth?: undefined;
88
+ padding?: undefined;
89
+ borderRadius?: undefined;
90
+ };
91
+ backgroundColor: string;
92
+ borderColor: string;
93
+ borderWidth: number;
94
+ borderDash: number[] | undefined;
95
+ type: AnnotationType;
96
+ adjustScaleRange: boolean | undefined;
97
+ enter: ({ element, }: {
98
+ element: ICommonAnnotationElement;
99
+ }, { chart, }: {
100
+ chart: TChart;
101
+ }) => void;
102
+ leave: ({ element, }: {
103
+ element: ICommonAnnotationElement;
104
+ }, { chart, }: {
105
+ chart: TChart;
106
+ }) => void;
107
+ onDragStart: () => (cord: ICoordinates, annotation: ICommonAnnotationsData) => void;
108
+ onDrag: () => (cord: ICoordinates, annotation: ICommonAnnotationsData) => void;
109
+ onDragEnd: () => (cord: ICoordinates, annotation: ICommonAnnotationsData) => void;
110
+ pointStyle: string;
111
+ resizable: boolean;
112
+ displayDragCoordinates: boolean;
113
+ hideLegend?: boolean;
114
+ labelOffsetPx?: number;
115
+ annotationAxis?: "x" | "y";
116
+ rotation?: number;
117
+ color?: string;
118
+ endValue?: number;
119
+ labelConfig?: import('../common.interface').IAnnotationLabelConfig;
120
+ value?: number;
121
+ xMin?: number;
122
+ xMax?: number;
123
+ yMin?: number;
124
+ yMax?: number;
125
+ xValue?: number;
126
+ yValue?: number;
127
+ radius?: number;
128
+ enableDrag?: boolean;
129
+ dragAxis?: import('../plugins/annotation-dragger-plugin/enums').DragAxis;
130
+ dragRange?: {
131
+ x?: [number, number];
132
+ y?: [number, number];
133
+ };
134
+ xScaleID?: string;
135
+ yScaleID?: string;
136
+ opacity?: number;
137
+ };
138
+ export declare const getAnnotation: ({ showAnnotations, annotationsData, }: IGetAnnotationsProps) => ICommonAnnotationElement[] | Record<string, any>[];
139
+ export {};
@@ -0,0 +1 @@
1
+ export declare const getChartFromCtx: (ctx: any) => any;
@@ -0,0 +1,8 @@
1
+ import { Chart, ChartConfiguration, Plugin } from 'chart.js';
2
+ /**
3
+ * Gets an example custom legend plugin for use in storybook.
4
+ * @param {string} customLegendContainerID - the id of the div container to put the generated legend in
5
+ */
6
+ export declare const getCustomLegendPlugin: (customLegendContainerID: string) => {
7
+ afterUpdate(chart: Chart, _args: Plugin, _options: ChartConfiguration): void;
8
+ };
@@ -0,0 +1,18 @@
1
+ import { ICommonOptions } from '../common.interface';
2
+ export 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
+ export interface IDraggableData {
12
+ dragData: IDraggableDataOptions;
13
+ }
14
+ /**
15
+ * @param {ICommonChartOptions} options - line chart options object
16
+ */
17
+ declare const getDraggableData: (options: ICommonOptions) => IDraggableData | object;
18
+ export default getDraggableData;
@@ -0,0 +1 @@
1
+ export declare const getGroupedColorScheme: (length: number, startingColor: string) => string[];
@@ -0,0 +1,15 @@
1
+ import { AlignOptions, ChartDirection, Position } from '../enums';
2
+ type TDragRange = {
3
+ x?: [number, number];
4
+ y?: [number, number];
5
+ };
6
+ export declare const normalizeTitle: (title: unknown) => string | string[];
7
+ export declare const normalizeCartesianDirection: (direction: unknown) => "vertical" | "horizontal";
8
+ export declare const normalizeChartDirection: (direction: unknown) => ChartDirection;
9
+ export declare const normalizeLegendPosition: (position: unknown, fallback: Position) => Position;
10
+ export declare const normalizeLegendAlign: (align: unknown, fallback: AlignOptions) => AlignOptions;
11
+ export declare const normalizeDragRange: (range?: {
12
+ x?: number[] | [number, number];
13
+ y?: number[] | [number, number];
14
+ }) => TDragRange;
15
+ export {};
@@ -0,0 +1,8 @@
1
+ import { TGeneratedLineChartDatasets } from '../../../line-chart/line-chart.interface';
2
+ /**
3
+ * Estimates whether any of the data series has values that are all close together
4
+ * - checks only the first and last values in each series (i.e. assumes they are ordered)
5
+ * - uses an equality check with tolerance for decimal precision noise
6
+ * - this is just an inexpensive "guesstimate" (full min/max detection can be used afterwards)
7
+ */
8
+ export declare const estimateDataSeriesHaveCloseValues: (generatedDatasets: TGeneratedLineChartDatasets) => boolean;
@@ -0,0 +1,33 @@
1
+ interface IGetSuggestedAxisRange {
2
+ data: number[];
3
+ beginAtZero: boolean;
4
+ autoAxisPadding: boolean;
5
+ }
6
+ /**
7
+ * Overrides the default chart.js axis range for some edge-cases:
8
+ * - when no data -> default range
9
+ * - when all values are close to zero -> default range
10
+ * - when all values are close to each other -> custom 5% padding
11
+ * - when autoAxisPadding is set -> custom 5% padding
12
+ * - all other cases fall back to chart.js default behaviour
13
+ *
14
+ * `autoAxisPadding` feature requirements:
15
+ * - specified by Truls and ported by Mark+Oleg
16
+ * - numbers that are equal (within tolerance) shall be presented as a straight line
17
+ * - all other data series shall use 90% of width of axis (5% padding each side)
18
+ * - the padding on each side shall be symmetric
19
+ *
20
+ * @param {object} args
21
+ * @param {array<number|null>} args.data
22
+ * @param {boolean} [args.beginAtZero]
23
+ * @param {boolean>} [args.autoAxisPadding]
24
+ * @returns {object} returns {min, max} pair
25
+ */
26
+ export declare const getSuggestedAxisRange: ({ data, beginAtZero, autoAxisPadding, }: IGetSuggestedAxisRange) => {
27
+ min: number;
28
+ max: number;
29
+ } | {
30
+ min: undefined;
31
+ max: undefined;
32
+ };
33
+ export {};
@@ -0,0 +1 @@
1
+ export declare const getTextWidth: (text: string, font: string) => number | undefined;
@@ -0,0 +1,4 @@
1
+ import { ICommonAnnotationElement } from '../common.interface';
2
+ export declare const toAnnotationObject: (annotationArr?: ICommonAnnotationElement[]) => {
3
+ annotations: {};
4
+ };
@@ -0,0 +1,4 @@
1
+ import { RefObject } from 'react';
2
+ import { Chart } from 'chart.js';
3
+ import { TLegendDatasets } from '../legend-component/legend-interface';
4
+ export declare const useGeneratedLabels: (chartRef: RefObject<Chart>, generatedDatasets: TLegendDatasets) => any[];
@@ -0,0 +1,28 @@
1
+ import { RefObject } from 'react';
2
+ import { Chart, LegendItem } from 'chart.js';
3
+ import { UnusedParameter } from '../common.interface';
4
+ export interface IUseLegendStateProps {
5
+ chartRef: RefObject<Chart>;
6
+ options: any;
7
+ }
8
+ /**
9
+ * Custom hook to manage legend state.
10
+ */
11
+ export declare const useLegendState: ({ chartRef, options }: IUseLegendStateProps) => {
12
+ legendClick: (_: UnusedParameter, legendItem: LegendItem) => void;
13
+ annotation: import('../common.interface').ICommonAnnotationElement[];
14
+ legend: {
15
+ position: any;
16
+ display: boolean | undefined;
17
+ align: "center" | "start" | "end";
18
+ labels: {
19
+ boxHeight: number;
20
+ boxWidth: number | undefined;
21
+ usePointStyle: boolean | undefined;
22
+ };
23
+ onClick: (_: UnusedParameter, legendItem: LegendItem) => void;
24
+ };
25
+ customLegendPlugin: {
26
+ htmlLegend: any;
27
+ };
28
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useLegend: () => {
2
+ state: import('../legend-component/state/legend-state-reducer').ILegendState;
3
+ dispatch: React.Dispatch<any>;
4
+ };
@@ -0,0 +1,4 @@
1
+ import { Dispatch } from 'react';
2
+ import { TLegendAction } from '../legend-component/state/legend-state-reducer';
3
+ import { TChartsOption } from '../legend-component/legend-interface';
4
+ export declare const useUpdateAnnotations: (options: TChartsOption, dispatch: Dispatch<TLegendAction>) => void;
@@ -0,0 +1,3 @@
1
+ import { ILegendDropZones } from './legend-interface';
2
+ declare const LegendDropZones: (legendDropZonesProps: ILegendDropZones) => import("react/jsx-runtime").JSX.Element;
3
+ export default LegendDropZones;
@@ -0,0 +1,47 @@
1
+ import { MouseEventHandler, RefObject } from 'react';
2
+ import { Chart, ChartArea } from 'chart.js';
3
+ import { IGeneratedScatterChartDataset, TGeneratedScatterChartDatasets, IScatterOptions } from '../../scatter-chart/scatter-chart.interface';
4
+ import { Position, ChartType } from '../enums';
5
+ import { IGeneratedLineChartDataset, ILineChartOptions, TGeneratedLineChartDatasets } from '../../line-chart/line-chart.interface';
6
+ import { IBarOptions, IGenerateBarChartDataset, TGenerateBarChartDatasets } from '../../bar-chart/bar-chart.interface';
7
+ import { IGeneratedPieChartDataset, IPieOptions, TGeneratedPieChartDatasets } from '../../pie-chart/pie-chart.interface';
8
+ export interface ILegendDropZone {
9
+ position: Position;
10
+ onDrop: () => void;
11
+ placeholderSize?: {
12
+ width?: number;
13
+ height?: number;
14
+ };
15
+ }
16
+ export interface ILegendDropZones {
17
+ chartArea?: ChartArea;
18
+ setLegendPosition: (position: Position) => void;
19
+ isDragging: boolean;
20
+ placeholderSize?: {
21
+ width?: number;
22
+ height?: number;
23
+ };
24
+ }
25
+ export type TLegendDataset = IGeneratedLineChartDataset | IGenerateBarChartDataset | IGeneratedPieChartDataset | IGeneratedScatterChartDataset;
26
+ export type TLegendDatasets = TGeneratedLineChartDatasets | TGenerateBarChartDatasets | TGeneratedPieChartDatasets | TGeneratedScatterChartDatasets;
27
+ export type TChartsOption = ILineChartOptions | IBarOptions | IPieOptions | IScatterOptions;
28
+ export interface ILegendItem {
29
+ hidden: boolean;
30
+ dataset: TLegendDataset;
31
+ handleClick: MouseEventHandler<HTMLDivElement>;
32
+ chartType: ChartType;
33
+ index: number;
34
+ }
35
+ export interface ILegendConfig {
36
+ options: TChartsOption;
37
+ generatedDatasets: TLegendDatasets;
38
+ chartType: ChartType;
39
+ }
40
+ export interface ILegend {
41
+ chartRef: RefObject<Chart>;
42
+ legendConfig: ILegendConfig;
43
+ }
44
+ export interface ILegendPanel extends ILegend {
45
+ legendPosition: Position;
46
+ isDragging: boolean;
47
+ }
@@ -0,0 +1,5 @@
1
+ import { IGeneratedLineChartDataset } from '../../../line-chart/line-chart.interface';
2
+ export interface ILineLegendItemProp {
3
+ dataset: IGeneratedLineChartDataset;
4
+ }
5
+ export declare const LegendItemLine: ({ dataset }: Record<string, any>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { ILegendItem } from '../legend-interface';
2
+ declare const LegendItem: ({ hidden, dataset, handleClick, chartType, index, }: ILegendItem) => import("react/jsx-runtime").JSX.Element;
3
+ export default LegendItem;
@@ -0,0 +1,3 @@
1
+ import { ILegendPanel } from './legend-interface';
2
+ declare const LegendPanel: import('react').ForwardRefExoticComponent<ILegendPanel & import('react').RefAttributes<HTMLDivElement>>;
3
+ export default LegendPanel;
@@ -0,0 +1,3 @@
1
+ import { ILegend } from './legend-interface';
2
+ declare const Legend: ({ chartRef, legendConfig }: ILegend) => import("react/jsx-runtime").JSX.Element;
3
+ export default Legend;
@@ -0,0 +1,3 @@
1
+ export declare const TOGGLE_DATA_VISIBILITY = "TOGGLE_DATA_VISIBILITY";
2
+ export declare const RESET_STATE = "RESET_STATE";
3
+ export declare const SET_ANNOTATION = "SET_ANNOTATION";
@@ -0,0 +1,14 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { ILegendState } from './legend-state-reducer';
3
+ import { TChartsOption } from '../legend-interface';
4
+ import { ICommonDataset } from '../../common.interface';
5
+ export declare const LegendContext: React.Context<{
6
+ state: ILegendState;
7
+ dispatch: React.Dispatch<any>;
8
+ } | undefined>;
9
+ export interface ILegendProviderProps {
10
+ children: ReactNode;
11
+ options: TChartsOption;
12
+ datasets?: ICommonDataset[];
13
+ }
14
+ export declare const LegendProvider: ({ children, options, datasets, }: ILegendProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { Chart } from 'chart.js';
2
+ import { TLegendDataset, TLegendDatasets } from '../legend-interface';
3
+ import { RESET_STATE, SET_ANNOTATION, TOGGLE_DATA_VISIBILITY } from './legend-action-types';
4
+ import { ICommonAnnotationElement, ICommonDataset } from '../../common.interface';
5
+ export interface ILegendState {
6
+ datasets: ICommonDataset[];
7
+ annotation: ICommonAnnotationElement[];
8
+ }
9
+ export type TLegendAction = {
10
+ type: typeof TOGGLE_DATA_VISIBILITY;
11
+ payload: {
12
+ chartInstance: Chart;
13
+ dsConfig: {
14
+ datasetIndex: number;
15
+ dataset: TLegendDataset;
16
+ datasets: TLegendDatasets;
17
+ };
18
+ annotationConfig: {
19
+ annotationIndex: number;
20
+ };
21
+ };
22
+ } | {
23
+ type: typeof RESET_STATE;
24
+ payload: ILegendState;
25
+ } | {
26
+ type: typeof SET_ANNOTATION;
27
+ payload: ICommonAnnotationElement[];
28
+ };
29
+ export declare const legendInitialState: ILegendState;
30
+ export declare const legendReducer: (state: ILegendState, action: TLegendAction) => ILegendState;
@@ -0,0 +1,27 @@
1
+ import { Position } from '../../enums';
2
+ export declare const LEGEND_MARGIN = 4;
3
+ interface IChartArea {
4
+ top: number;
5
+ left: number;
6
+ bottom: number;
7
+ right: number;
8
+ }
9
+ interface IChart {
10
+ height?: number;
11
+ width?: number;
12
+ chartArea: IChartArea;
13
+ }
14
+ interface ILegendStyle {
15
+ left: number | undefined;
16
+ right: number | undefined;
17
+ top: number | undefined;
18
+ bottom: number | undefined;
19
+ maxHeight: number;
20
+ maxWidth: number;
21
+ margin: number;
22
+ }
23
+ /**
24
+ * Creates a style object for positioning and sizing the legend panel based on the chart dimensions and legend position.
25
+ */
26
+ export declare const createLegendStyle: (legendPosition: Position, chart: IChart | null) => ILegendStyle;
27
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Chart, LegendItem } from 'chart.js';
2
+ export declare const getGeneratedLabels: (chart: Chart) => LegendItem[];
@@ -0,0 +1,15 @@
1
+ import { ChartType, Plugin, Scale } from 'chart.js';
2
+ export interface IScales {
3
+ x: Scale;
4
+ y: Scale;
5
+ [key: string]: Scale;
6
+ }
7
+ export interface AnnotationDraggerPluginOptions {
8
+ enabled: boolean;
9
+ }
10
+ declare module 'chart.js' {
11
+ interface PluginOptionsByType<TType extends ChartType> {
12
+ annotationDraggerPlugin?: AnnotationDraggerPluginOptions;
13
+ }
14
+ }
15
+ export declare const annotationDraggerPlugin: Plugin;
@@ -0,0 +1,7 @@
1
+ export interface TStoredAnnotationPosition {
2
+ x: number;
3
+ y: number;
4
+ [key: string]: any;
5
+ }
6
+ export declare const setAnnotationPosition: (persistenceId: string | undefined, annotationId: string, pos: TStoredAnnotationPosition) => void;
7
+ export declare const getAnnotationPosition: (persistenceId: string | undefined, annotationId: string) => TStoredAnnotationPosition | undefined;
@@ -0,0 +1,21 @@
1
+ export declare enum FontStyle {
2
+ DEFAULT = "14px Arial",
3
+ CUSTOM = "16px Arial"
4
+ }
5
+ export declare enum MouseEvents {
6
+ MOUSEDOWN = "mousedown",
7
+ MOUSEMOVE = "mousemove",
8
+ MOUSEUP = "mouseup"
9
+ }
10
+ export declare enum AnnotationType {
11
+ POINT = "point",
12
+ BOX = "box",
13
+ LINE = "line",
14
+ ELLIPSE = "ellipse",
15
+ LABEL = "label"
16
+ }
17
+ export declare enum DragAxis {
18
+ X = "x",
19
+ Y = "y",
20
+ Both = "both"
21
+ }
@@ -0,0 +1,6 @@
1
+ import { Chart } from 'chart.js';
2
+ import { IScales } from './annotation-dragger-plugin';
3
+ import { ICommonAnnotationsData } from '../../common.interface';
4
+ export declare const handleAnnotationMouseDown: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales, annotations: Record<string, ICommonAnnotationsData>, setDraggingState: (isDragging: boolean, annotation: ICommonAnnotationsData | null, dragStartX: number, dragStartY: number) => void, hoveredAnnotationId: string | null) => void;
5
+ export declare const handleAnnotationMouseMove: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales, isDragging: boolean, activeAnnotation: ICommonAnnotationsData | null, dragStartX: number, dragStartY: number, chart: Chart) => void;
6
+ export declare const handleAnnotationMouseUp: (isDragging: boolean, activeAnnotation: ICommonAnnotationsData | null, chart: Chart, canvas: HTMLCanvasElement, setDraggingState: (isDragging: boolean, annotation: ICommonAnnotationsData | null) => void, persistenceId?: string) => void;