@oliasoft-open-source/charts-library 8.0.6 → 9.0.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.
- package/dist/index.d.ts +15 -2249
- package/dist/index.js +920 -894
- package/dist/src/components/bar-chart/bar-chart-const.d.ts +2 -0
- package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +3 -0
- package/dist/src/components/bar-chart/bar-chart.d.ts +43 -0
- package/dist/src/components/bar-chart/bar-chart.interface.d.ts +252 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-data-labels.d.ts +10 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-scales.d.ts +4 -0
- package/dist/src/components/bar-chart/utils/get-bar-chart-tooltips.d.ts +6 -0
- package/dist/src/components/bar-chart/utils/use-bar-chart-config.d.ts +13 -0
- package/dist/src/components/bar-chart/utils/use-bar-chart-options.d.ts +54 -0
- package/dist/src/components/common/common.interface.d.ts +510 -0
- package/dist/src/components/common/controls-portal.d.ts +7 -0
- package/dist/src/components/common/enums.d.ts +104 -0
- package/dist/src/components/common/helpers/add-transparency/add-transparency.d.ts +1 -0
- package/dist/src/components/common/helpers/callout-helpers/callout-helpers.d.ts +25 -0
- package/dist/src/components/common/helpers/chart-border-plugin.d.ts +16 -0
- package/dist/src/components/common/helpers/chart-consts.d.ts +40 -0
- package/dist/src/components/common/helpers/chart-utils.d.ts +86 -0
- package/dist/src/components/common/helpers/custom-format-number.d.ts +1 -0
- package/dist/src/components/common/helpers/download-png.d.ts +3 -0
- package/dist/src/components/common/helpers/get-cartesian-scale-options.d.ts +28 -0
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +139 -0
- package/dist/src/components/common/helpers/get-chart-from-ctx.d.ts +1 -0
- package/dist/src/components/common/helpers/get-draggableData.d.ts +18 -0
- package/dist/src/components/common/helpers/get-grouped-color-scheme/get-grouped-color-scheme.d.ts +12 -0
- package/dist/src/components/common/helpers/input-normalizers.d.ts +15 -0
- package/dist/src/components/common/helpers/range/estimate-data-series-have-close-values.d.ts +8 -0
- package/dist/src/components/common/helpers/range/range.d.ts +33 -0
- package/dist/src/components/common/helpers/to-annotation.d.ts +4 -0
- package/dist/src/components/common/hooks/use-generated-labels.d.ts +4 -0
- package/dist/src/components/common/hooks/use-legend-state.d.ts +28 -0
- package/dist/src/components/common/hooks/use-legend.d.ts +4 -0
- package/dist/src/components/common/hooks/use-update-annotations.d.ts +4 -0
- package/dist/src/components/common/legend-component/legend-dropzone.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-interface.d.ts +50 -0
- package/dist/src/components/common/legend-component/legend-item/LegendItemLine.d.ts +5 -0
- package/dist/src/components/common/legend-component/legend-item/legend-item.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-panel.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend-position-storage.d.ts +3 -0
- package/dist/src/components/common/legend-component/legend.d.ts +3 -0
- package/dist/src/components/common/legend-component/state/legend-action-types.d.ts +3 -0
- package/dist/src/components/common/legend-component/state/legend-context.d.ts +14 -0
- package/dist/src/components/common/legend-component/state/legend-state-reducer.d.ts +30 -0
- package/dist/src/components/common/legend-component/utils/create-style-object.d.ts +27 -0
- package/dist/src/components/common/legend-component/utils/get-generated-labels.d.ts +3 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-dragger-plugin.d.ts +15 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/annotation-position-storage.d.ts +7 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/enums.d.ts +23 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/event-helpers.d.ts +6 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/helpers.d.ts +53 -0
- package/dist/src/components/common/plugins/annotation-dragger-plugin/point-annotation-label.d.ts +5 -0
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts +9 -0
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +18 -0
- package/dist/src/components/common/plugins/gradient-background-plugin/enums.d.ts +11 -0
- package/dist/src/components/common/plugins/gradient-background-plugin/gradient-background-plugin.d.ts +2 -0
- package/dist/src/components/line-chart/constants/default-translations.d.ts +25 -0
- package/dist/src/components/line-chart/constants/line-chart-consts.d.ts +13 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +57 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-options.d.ts +6 -0
- package/dist/src/components/line-chart/controls/axes-options/axes-validation.d.ts +8 -0
- package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +19 -0
- package/dist/src/components/line-chart/controls/controls.d.ts +4 -0
- package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +14 -0
- package/dist/src/components/line-chart/controls/drag-options.d.ts +23 -0
- package/dist/src/components/line-chart/controls/line-options.d.ts +19 -0
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +32 -0
- package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +20 -0
- package/dist/src/components/line-chart/hooks/use-chart-plugins.d.ts +7 -0
- package/dist/src/components/line-chart/hooks/use-chart-state.d.ts +12 -0
- package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +12 -0
- package/dist/src/components/line-chart/initialize/config.d.ts +12 -0
- package/dist/src/components/line-chart/initialize/initialize-line-chart.d.ts +17 -0
- package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +3 -0
- package/dist/src/components/line-chart/line-chart.d.ts +42 -0
- package/dist/src/components/line-chart/line-chart.interface.d.ts +458 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/callout-plugin.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/callout-plugin/helpers.d.ts +42 -0
- package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +17 -0
- package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +8 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/draw.d.ts +39 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/line-markers-plugin.d.ts +10 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/types.d.ts +204 -0
- package/dist/src/components/line-chart/plugins/line-markers-plugin/utils.d.ts +40 -0
- package/dist/src/components/line-chart/plugins/plugin-constants.d.ts +11 -0
- package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +9 -0
- package/dist/src/components/line-chart/state/action-types.d.ts +12 -0
- package/dist/src/components/line-chart/state/helpers.d.ts +13 -0
- package/dist/src/components/line-chart/state/initial-state.d.ts +11 -0
- package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +2 -0
- package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +15 -0
- package/dist/src/components/line-chart/state/state.interfaces.d.ts +26 -0
- package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +2 -0
- package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +18 -0
- package/dist/src/components/line-chart/utils/check-custom-option/check-custom-option.d.ts +12 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/datalabels-alignment.interface.d.ts +20 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts +8 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +11 -0
- package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +6 -0
- package/dist/src/components/line-chart/utils/enums.d.ts +4 -0
- package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +8 -0
- package/dist/src/components/line-chart/utils/get-annotations-data.d.ts +8 -0
- package/dist/src/components/line-chart/utils/get-axes-data-from-metasets.d.ts +5 -0
- package/dist/src/components/line-chart/utils/get-axis-range-by-type.d.ts +9 -0
- package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +16 -0
- package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +5 -0
- package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +31 -0
- package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +24 -0
- package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +8 -0
- package/dist/src/components/pie-chart/pie-chart-defalut-props.interface.d.ts +50 -0
- package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +3 -0
- package/dist/src/components/pie-chart/pie-chart.d.ts +38 -0
- package/dist/src/components/pie-chart/pie-chart.interface.d.ts +150 -0
- package/dist/src/components/pie-chart/use-pie-chart-config.d.ts +42 -0
- package/dist/src/components/scatter-chart/hooks/use-scatter-chart-config.d.ts +69 -0
- package/dist/src/components/scatter-chart/scatter-chart-default-props.interface.d.ts +73 -0
- package/dist/src/components/scatter-chart/scatter-chart-get-default-props.d.ts +4 -0
- package/dist/src/components/scatter-chart/scatter-chart.d.ts +41 -0
- package/dist/src/components/scatter-chart/scatter-chart.interface.d.ts +193 -0
- package/dist/src/components/scatter-chart/utils/get-scales-config.d.ts +5 -0
- package/dist/src/components/scatter-chart/utils/get-tooltip-config.d.ts +21 -0
- package/package.json +34 -34
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
/** Annotation shape identifiers. */
|
|
11
|
+
export declare enum AnnotationType {
|
|
12
|
+
POINT = "point",
|
|
13
|
+
BOX = "box",
|
|
14
|
+
LINE = "line",
|
|
15
|
+
ELLIPSE = "ellipse",
|
|
16
|
+
LABEL = "label"
|
|
17
|
+
}
|
|
18
|
+
/** Allowed axes for annotation dragging. */
|
|
19
|
+
export declare enum DragAxis {
|
|
20
|
+
X = "x",
|
|
21
|
+
Y = "y",
|
|
22
|
+
Both = "both"
|
|
23
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Chart } from 'chart.js';
|
|
2
|
+
import { IScales } from './annotation-dragger-plugin.js';
|
|
3
|
+
import { ICommonAnnotationsData } from '../../common.interface.js';
|
|
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;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Chart } from 'chart.js';
|
|
2
|
+
import { ICommonAnnotationsData } from '../../common.interface.js';
|
|
3
|
+
import { IScales } from './annotation-dragger-plugin.js';
|
|
4
|
+
import { AnnotationType, DragAxis } from './enums';
|
|
5
|
+
export declare const getMousePosition: (event: MouseEvent, canvas: HTMLCanvasElement) => {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const getMousePositionInCoordinates: (event: MouseEvent, canvas: HTMLCanvasElement, scales: IScales, xScaleID: string, yScaleID: string) => {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
export declare const calculateAnnotationMetricsInValues: (annotation: ICommonAnnotationsData) => {
|
|
14
|
+
centerX: number | undefined;
|
|
15
|
+
centerY: number | undefined;
|
|
16
|
+
width: number | undefined;
|
|
17
|
+
height: number | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const calculateAnnotationMetricsInValuesInPixels: (annotation: ICommonAnnotationsData, scales: IScales, xScaleID: string, yScaleID: string) => {
|
|
20
|
+
centerX: number | undefined;
|
|
21
|
+
centerY: number | undefined;
|
|
22
|
+
width: number | undefined;
|
|
23
|
+
height: number | undefined;
|
|
24
|
+
};
|
|
25
|
+
export interface IIsWithinChartAreaProps {
|
|
26
|
+
x?: number;
|
|
27
|
+
y?: number;
|
|
28
|
+
chartArea: {
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
top: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
};
|
|
34
|
+
scales: IScales;
|
|
35
|
+
metrics: {
|
|
36
|
+
width?: number;
|
|
37
|
+
height?: number;
|
|
38
|
+
};
|
|
39
|
+
resizable?: boolean;
|
|
40
|
+
dragRange?: {
|
|
41
|
+
x?: [number, number];
|
|
42
|
+
y?: [number, number];
|
|
43
|
+
} | null;
|
|
44
|
+
annotationType?: AnnotationType;
|
|
45
|
+
xScaleID: string;
|
|
46
|
+
yScaleID: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const isWithinChartArea: ({ x, y, chartArea, scales, metrics, resizable, dragRange, annotationType, xScaleID, yScaleID, }: IIsWithinChartAreaProps) => boolean;
|
|
49
|
+
export declare const updateAnnotationPositionWithinBounds: (axis: DragAxis, newPosition: number, activeAnnotation: ICommonAnnotationsData, chart: Chart, scales: IScales, xScaleID: string, yScaleID: string, metrics?: {
|
|
50
|
+
width?: number;
|
|
51
|
+
height?: number;
|
|
52
|
+
}) => void;
|
|
53
|
+
export declare const setAnnotationBorderWidth: (chart: Chart, annotationId?: string, borderWidth?: number) => void;
|
package/dist/src/components/common/plugins/annotation-dragger-plugin/point-annotation-label.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IScales } from './annotation-dragger-plugin.js';
|
|
2
|
+
import { ICommonAnnotationsData } from '../../common.interface.js';
|
|
3
|
+
export declare const annotationLabel: (ctx: CanvasRenderingContext2D, annotations: Record<string, ICommonAnnotationsData & {
|
|
4
|
+
label: Record<string, any>;
|
|
5
|
+
}>, scales: IScales) => void;
|
package/dist/src/components/common/plugins/ellipsis-annotation-plugin/compute-ellipse-geometry.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Scale } from 'chart.js';
|
|
2
|
+
import type { IEllipsePoints } from './ellipsis-annotation-plugin.ts';
|
|
3
|
+
export declare const computeEllipseGeometry: (ellipsePoints: IEllipsePoints, xScale: Scale, yScale: Scale) => {
|
|
4
|
+
cx: number;
|
|
5
|
+
cy: number;
|
|
6
|
+
radiusX: number;
|
|
7
|
+
radiusY: number;
|
|
8
|
+
angle: number;
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Chart, ChartDataset, ScatterDataPoint } from 'chart.js';
|
|
2
|
+
export interface IPoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface IEllipsePoints {
|
|
7
|
+
major: [IPoint, IPoint];
|
|
8
|
+
minor: [IPoint, IPoint];
|
|
9
|
+
}
|
|
10
|
+
export interface ICustomDataPoint extends ScatterDataPoint {
|
|
11
|
+
ellipsePoints?: IEllipsePoints;
|
|
12
|
+
}
|
|
13
|
+
export interface ICustomDataset extends ChartDataset<any, ICustomDataPoint[]> {
|
|
14
|
+
}
|
|
15
|
+
export declare const ellipsisAnnotationPlugin: {
|
|
16
|
+
id: string;
|
|
17
|
+
afterDatasetsDraw(chart: Chart<'scatter'>): void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Direction of the background gradient between chart-area edges or corners. */
|
|
2
|
+
export declare enum GradientDirection {
|
|
3
|
+
TopToBottom = 0,
|
|
4
|
+
BottomToTop = 1,
|
|
5
|
+
LeftToRight = 2,
|
|
6
|
+
RightToLeft = 3,
|
|
7
|
+
TopLeftToBottomRight = 4,
|
|
8
|
+
BottomRightToTopLeft = 5,
|
|
9
|
+
BottomLeftToTopRight = 6,
|
|
10
|
+
TopRightToBottomLeft = 7
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare enum defaultTranslations {
|
|
2
|
+
label = "Label",
|
|
3
|
+
pointsLines = "Points & lines",
|
|
4
|
+
linesOnly = "Lines only",
|
|
5
|
+
pointsOnly = "Points only",
|
|
6
|
+
axesOptions = "Axes options",
|
|
7
|
+
resetAxes = "Reset Axes",
|
|
8
|
+
done = "Done",
|
|
9
|
+
downloadAsPNG = "Download as PNG",
|
|
10
|
+
showChart = "Show chart",
|
|
11
|
+
showTable = "Show table",
|
|
12
|
+
dragToZoom = "Drag to zoom",
|
|
13
|
+
dragToPan = "Drag to pan",
|
|
14
|
+
dragToMovePoints = "Drag to move points",
|
|
15
|
+
dragToMoveAnnotation = "Drag to move annotation",
|
|
16
|
+
dragDisabled = "Drag disabled",
|
|
17
|
+
hideLegend = "Hide Legend",
|
|
18
|
+
showLegend = "Show Legend",
|
|
19
|
+
mustHaveAValue = "Must have a value",
|
|
20
|
+
mustBeANumber = "Must be a number",
|
|
21
|
+
mustBeLessThanMax = "Must be less than max",
|
|
22
|
+
mustBeGreaterThanMin = "Must be greater than min",
|
|
23
|
+
doubleClickToReset = "Double click on canvas to reset",
|
|
24
|
+
orDoubleClickToCanvas = "or double click on canvas"
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DEFAULT_POINT_RADIUS = 2;
|
|
2
|
+
export declare const DEFAULT_HOVER_RADIUS = 5;
|
|
3
|
+
export declare const DEFAULT_BORDER_WIDTH = 1;
|
|
4
|
+
export declare const BORDER_JOIN_STYLE = "round";
|
|
5
|
+
export declare const DEFAULT_BACKGROUND_COLOR = "transparent";
|
|
6
|
+
export declare const ZOOM_BOX_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.1)";
|
|
7
|
+
export declare const DOUBLE_CLICK = "dblclick";
|
|
8
|
+
export declare const INIT_KEYS: {
|
|
9
|
+
TRANSLATIONS: string;
|
|
10
|
+
LANGUAGE_KEY: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const LOWER_BOUND = 0.0001;
|
|
13
|
+
export declare const UPPER_BOUND = 10000000;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { TChart } from '../../../common/common.interface.js';
|
|
3
|
+
import { IUnitOptions } from '../../line-chart.interface';
|
|
4
|
+
import { IAxisState, IState } from '../../state/state.interfaces';
|
|
5
|
+
export interface IDepthType {
|
|
6
|
+
selectedDepthType?: string;
|
|
7
|
+
setSelectedDepthType?: (type: string) => void;
|
|
8
|
+
options?: Array<string>;
|
|
9
|
+
}
|
|
10
|
+
export interface IAxisControlLabel {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IAxesOptions {
|
|
15
|
+
chartRef: RefObject<TChart | null>;
|
|
16
|
+
state: IState;
|
|
17
|
+
controlsAxesLabels: IAxisControlLabel[];
|
|
18
|
+
onUpdateAxes: ({ axes }: {
|
|
19
|
+
axes: IAxisState;
|
|
20
|
+
}) => void;
|
|
21
|
+
onResetAxes: () => void;
|
|
22
|
+
onUpdateEdited: (edited: boolean) => void;
|
|
23
|
+
depthType?: IDepthType | object;
|
|
24
|
+
close?: () => void;
|
|
25
|
+
}
|
|
26
|
+
export interface IOnEdit {
|
|
27
|
+
name?: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface IAxisFormState {
|
|
32
|
+
id: string;
|
|
33
|
+
min: number | string;
|
|
34
|
+
max: number | string;
|
|
35
|
+
unit?: string | IUnitOptions;
|
|
36
|
+
}
|
|
37
|
+
export type IInitializeAxisFormState = IAxisFormState[];
|
|
38
|
+
export interface IError {
|
|
39
|
+
id: string;
|
|
40
|
+
min: string[];
|
|
41
|
+
max: string[];
|
|
42
|
+
}
|
|
43
|
+
export interface IFormState extends IInitializeAxisFormState {
|
|
44
|
+
errors?: IError[];
|
|
45
|
+
valid?: boolean;
|
|
46
|
+
}
|
|
47
|
+
type ActionType = 'reset' | 'valueUpdated' | 'unitUpdated';
|
|
48
|
+
export type AxisKey = 'min' | 'max' | 'unit';
|
|
49
|
+
interface ActionPayload extends IOnEdit {
|
|
50
|
+
axes?: IAxisState[];
|
|
51
|
+
chartRef?: RefObject<TChart | null>;
|
|
52
|
+
}
|
|
53
|
+
export interface IAction {
|
|
54
|
+
type: ActionType;
|
|
55
|
+
payload: ActionPayload;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IAxesOptions } from './axes-options-interfaces';
|
|
2
|
+
interface IAxesOptionsWithTranslations extends IAxesOptions {
|
|
3
|
+
translations: Record<string, string>;
|
|
4
|
+
}
|
|
5
|
+
export declare const AxesOptions: (optionsPopover: IAxesOptionsWithTranslations) => import("react").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Dispatch, ReactNode, RefObject } from 'react';
|
|
2
|
+
import { TChart } from '../../common/common.interface.js';
|
|
3
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
4
|
+
import { IState } from '../state/state.interfaces';
|
|
5
|
+
export interface IControls {
|
|
6
|
+
headerComponent?: ReactNode;
|
|
7
|
+
subheaderComponent?: ReactNode;
|
|
8
|
+
table?: ReactNode;
|
|
9
|
+
chartRef: RefObject<TChart | null>;
|
|
10
|
+
state: IState;
|
|
11
|
+
options: ILineChartOptions;
|
|
12
|
+
dispatch: Dispatch<any>;
|
|
13
|
+
translations: Record<string, string>;
|
|
14
|
+
controlsPortalId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AxisControls {
|
|
17
|
+
id?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IControls } from './controls-interfaces';
|
|
3
|
+
declare const Controls: ({ table, headerComponent, subheaderComponent, chartRef, state, options, dispatch, translations, controlsPortalId, }: IControls) => React.JSX.Element;
|
|
4
|
+
export default Controls;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IDragOptions {
|
|
2
|
+
onTogglePan: () => void;
|
|
3
|
+
onToggleZoom: () => void;
|
|
4
|
+
panEnabled: boolean;
|
|
5
|
+
zoomEnabled: boolean;
|
|
6
|
+
enableDragPoints?: boolean;
|
|
7
|
+
enableDragAnnotation?: boolean;
|
|
8
|
+
isDragDataAllowed?: boolean;
|
|
9
|
+
isDragAnnotationAllowed?: boolean;
|
|
10
|
+
onToggleDragAnnotation: () => void;
|
|
11
|
+
onToggleDragPoints: () => void;
|
|
12
|
+
onDisableDragOptions: () => void;
|
|
13
|
+
translations: Record<string, string>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IMenuSection } from '@oliasoft-open-source/react-ui-library';
|
|
2
|
+
import { IDragOptions } from './drag-options-interfaces';
|
|
3
|
+
export declare function getDragOptions({ onTogglePan, onToggleZoom, panEnabled, zoomEnabled, enableDragPoints, enableDragAnnotation, isDragDataAllowed, isDragAnnotationAllowed, onToggleDragAnnotation, onToggleDragPoints, onDisableDragOptions, translations: { dragToZoom, doubleClickToReset, dragToPan, dragToMovePoints, dragDisabled, dragToMoveAnnotation }, }: IDragOptions): ({
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
icon: import("react").JSX.Element;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
type: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
} | {
|
|
11
|
+
description?: undefined;
|
|
12
|
+
label: string;
|
|
13
|
+
icon: import("react").JSX.Element;
|
|
14
|
+
selected: boolean | undefined;
|
|
15
|
+
type: string;
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
})[];
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('./drag-options-interfaces').IDragOptions} obj
|
|
20
|
+
*/
|
|
21
|
+
export declare const DragOptions: ({ options }: {
|
|
22
|
+
options: IMenuSection[];
|
|
23
|
+
}) => import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IMenuSection } from '@oliasoft-open-source/react-ui-library';
|
|
2
|
+
interface ILineOptions {
|
|
3
|
+
lineEnabled: boolean;
|
|
4
|
+
onToggleLine: () => void;
|
|
5
|
+
onTogglePoints: () => void;
|
|
6
|
+
pointsEnabled: boolean;
|
|
7
|
+
translations: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function getLineOptions({ lineEnabled, onToggleLine, onTogglePoints, pointsEnabled, translations, }: ILineOptions): {
|
|
10
|
+
type: string;
|
|
11
|
+
label: string;
|
|
12
|
+
icon: import("react").JSX.Element;
|
|
13
|
+
selected: boolean;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
}[];
|
|
16
|
+
export declare const LineOptions: ({ options }: {
|
|
17
|
+
options: IMenuSection[];
|
|
18
|
+
}) => import("react").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Dispatch, KeyboardEvent, RefObject, SetStateAction } from 'react';
|
|
2
|
+
import { ChartEvent } from 'chart.js';
|
|
3
|
+
import { ICommonDataValue, ICommonHoveredItems, TChart } from '../../common/common.interface.js';
|
|
4
|
+
import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
|
|
5
|
+
import { IAxisState, IState } from '../state/state.interfaces';
|
|
6
|
+
interface IUseChartFunctions {
|
|
7
|
+
chartRef: RefObject<TChart | null>;
|
|
8
|
+
state: IState;
|
|
9
|
+
options: ILineChartOptions;
|
|
10
|
+
dispatch: Dispatch<any>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook that encapsulates the chart-related functions and their dependencies
|
|
14
|
+
*/
|
|
15
|
+
export declare const useChartFunctions: ({ chartRef, state, options, dispatch }: IUseChartFunctions) => {
|
|
16
|
+
resetZoom: () => void;
|
|
17
|
+
onHover: (hoveredPoint: ICommonDataValue | null, setHoveredPoint: Dispatch<SetStateAction<ICommonDataValue | null>>, datasets: TGeneratedLineChartDatasets) => (evt: ChartEvent, hoveredItems: ICommonHoveredItems[]) => void;
|
|
18
|
+
handleDownload: () => void;
|
|
19
|
+
handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
20
|
+
handleKeyUp: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
21
|
+
controlsAxesLabels: {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
}[];
|
|
25
|
+
updateAxesRangesFromChart: () => void;
|
|
26
|
+
onResetAxes: () => void;
|
|
27
|
+
onUpdateAxes: ({ axes }: {
|
|
28
|
+
axes: IAxisState;
|
|
29
|
+
}) => void;
|
|
30
|
+
onUpdateEdited: (edited: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Dispatch, RefObject } from 'react';
|
|
2
|
+
import { ChartOptions } from 'chart.js';
|
|
3
|
+
import { TChart } from '../../common/common.interface.js';
|
|
4
|
+
import { IState } from '../state/state.interfaces';
|
|
5
|
+
import { ILineChartOptions, TGeneratedLineChartDatasets } from '../line-chart.interface';
|
|
6
|
+
interface IUseChartOptions {
|
|
7
|
+
chartRef: RefObject<TChart | null>;
|
|
8
|
+
state: IState;
|
|
9
|
+
options: ILineChartOptions;
|
|
10
|
+
dispatch: Dispatch<any>;
|
|
11
|
+
generatedDatasets: TGeneratedLineChartDatasets;
|
|
12
|
+
persistenceId?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Custom hook to generate chart options.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useChartOptions: ({ chartRef, state, options, dispatch, generatedDatasets, persistenceId, }: IUseChartOptions) => ChartOptions<'line'> & {
|
|
18
|
+
persistenceId?: string;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IState } from '../state/state.interfaces';
|
|
2
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
3
|
+
interface IUseChartState {
|
|
4
|
+
options: ILineChartOptions;
|
|
5
|
+
state: IState;
|
|
6
|
+
persistenceId?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hook for managing the state of the chart.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useChartState: ({ options, state, persistenceId }: IUseChartState) => void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dispatch } from 'react';
|
|
2
|
+
export declare const useToggleHandlers: (dispatch: Dispatch<any>) => {
|
|
3
|
+
onToggleLegend: () => void;
|
|
4
|
+
onToggleLine: () => void;
|
|
5
|
+
onTogglePan: () => void;
|
|
6
|
+
onTogglePoints: () => void;
|
|
7
|
+
onToggleTable: () => void;
|
|
8
|
+
onToggleZoom: () => void;
|
|
9
|
+
onToggleDragPoints: () => void;
|
|
10
|
+
onToggleDragAnnotation: () => void;
|
|
11
|
+
onDisableDragOptions: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve the value for the given key from the config object.
|
|
3
|
+
* @param {string} key - The key to access the corresponding value in the config object.
|
|
4
|
+
* @returns {*} - The value associated with the given key in the config object or config.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getConfig: (key?: string) => any;
|
|
7
|
+
/**
|
|
8
|
+
* Set a new value for the given key in the config object.
|
|
9
|
+
* @param {string} key - The key to access the corresponding value in the config object.
|
|
10
|
+
* @param {*} newValue - The new value to be set for the given key.
|
|
11
|
+
*/
|
|
12
|
+
export declare const setConfig: (key: string, newValue: string | Record<string, string>) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Updates the shared chart configuration, including the language and translated control labels.
|
|
3
|
+
*
|
|
4
|
+
* Call during application setup before rendering charts. Configuration is shared across chart instances;
|
|
5
|
+
* this is not a per-chart configuration API. Each call sets the language key (default `en`) and updates
|
|
6
|
+
* the supplied configuration entries. Non-primitive entries other than translations are shallow-copied.
|
|
7
|
+
*
|
|
8
|
+
* @param options - Language key, translations and other shared configuration entries.
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* initializeLineChart({ languageKey: 'en' });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const initializeLineChart: ({ languageKey, ...options }: {
|
|
15
|
+
[x: string]: any;
|
|
16
|
+
languageKey?: string | undefined;
|
|
17
|
+
}) => void;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ILineChartData, ILineChartOptionsInput, ILineChartProps } from './line-chart.interface';
|
|
2
|
+
export declare const normalizeLineChartOptions: (options?: ILineChartOptionsInput) => ILineChartData['options'];
|
|
3
|
+
export declare const getDefaultProps: (props: ILineChartProps) => ILineChartData;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import 'chartjs-adapter-date-fns';
|
|
2
|
+
import { ILineChartProps } from './line-chart.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Renders an interactive line chart with multiple axes, annotations, a legend and chart controls.
|
|
5
|
+
*
|
|
6
|
+
* Pass partial configuration through `chart`; omitted settings receive component defaults.
|
|
7
|
+
* The example uses sample data, labels and a height of 320 pixels; these are not default values.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Defaults: bottom X axis, left Y axis, visible lines and points, bottom-left legend, and zoom enabled.
|
|
11
|
+
* Pan, data labels, minor grid lines and annotations are disabled. No fixed width or height is assigned.
|
|
12
|
+
* Performance mode is enabled by default, disabling animations.
|
|
13
|
+
* The linked reference lists the complete normalized default configuration.
|
|
14
|
+
*
|
|
15
|
+
* @see https://gitlab.com/oliasoft-open-source/charts-library/-/blob/master/README.md#linechart
|
|
16
|
+
*
|
|
17
|
+
* @param props - Chart data and options, plus optional header, subheader and table content.
|
|
18
|
+
* @returns The chart canvas and its associated UI.
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <LineChart chart={{
|
|
22
|
+
* data: {
|
|
23
|
+
* datasets: [{
|
|
24
|
+
* label: 'DS A',
|
|
25
|
+
* data: [{ x: 0, y: 10 }, { x: 1, y: 20 }, { x: 2, y: 15 }],
|
|
26
|
+
* }],
|
|
27
|
+
* },
|
|
28
|
+
* options: {
|
|
29
|
+
* axes: {
|
|
30
|
+
* x: [{ label: 'X', position: 'bottom' }],
|
|
31
|
+
* y: [{ label: 'Y', position: 'left' }],
|
|
32
|
+
* },
|
|
33
|
+
* chartStyling: { height: 320 },
|
|
34
|
+
* legend: { display: true, position: 'bottom-left' },
|
|
35
|
+
* graph: { lineTension: 0.01, showDataLabels: false },
|
|
36
|
+
* chartOptions: { showLine: true, showPoints: true },
|
|
37
|
+
* },
|
|
38
|
+
* }} />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const LineChartWithLegend: (props: ILineChartProps) => import("react").JSX.Element;
|
|
42
|
+
export { LineChartWithLegend as LineChart };
|