@oliasoft-open-source/charts-library 3.6.1 → 3.6.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.
- package/dist/declaration.d.ts +8 -0
- package/dist/index.js +56 -27
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +1 -2
- package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +1 -2
- package/dist/src/components/common/common.interface.d.ts +2 -1
- package/dist/src/components/common/helpers/chart-border-plugin.d.ts +2 -2
- package/dist/src/components/common/helpers/chart-utils.d.ts +91 -0
- package/dist/src/components/common/helpers/get-custom-legend-plugin-example.d.ts +1 -1
- package/dist/src/components/line-chart/controls/axes-options/axes-options-interfaces.d.ts +2 -2
- package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +2 -2
- package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +1 -1
- package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +2 -4
- package/dist/src/components/line-chart/hooks/use-chart-plugins.d.ts +7 -0
- package/dist/src/components/line-chart/legend/legend-interface.d.ts +1 -1
- package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +2 -99
- package/dist/src/components/line-chart/line-chart.interface.d.ts +3 -3
- package/dist/src/components/line-chart/state/initial-state.d.ts +4 -26
- package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +1 -1
- package/dist/src/components/line-chart/utils/get-generated-labels.d.ts +1 -0
- package/package.json +3 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Options } from 'chartjs-plugin-datalabels';
|
|
2
1
|
import { IBarOptions } from './bar-chart.interface';
|
|
3
2
|
type ExtendedDisplayOptions = 'auto' | boolean;
|
|
4
|
-
interface IExtendedDataLabelsOptions
|
|
3
|
+
interface IExtendedDataLabelsOptions {
|
|
5
4
|
display: ExtendedDisplayOptions;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChartEvent, ChartTypeRegistry, LinearScaleOptions, Plugin } from 'chart.js';
|
|
2
2
|
import { AlignOptions, Position } from './helpers/enums';
|
|
3
|
+
export type TAxisPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
4
|
export interface ICommonDataValue {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -124,7 +125,7 @@ export interface ICommonHoveredItems {
|
|
|
124
125
|
}
|
|
125
126
|
export interface ICommonChartPlugins {
|
|
126
127
|
legend: {
|
|
127
|
-
position:
|
|
128
|
+
position: TAxisPosition;
|
|
128
129
|
};
|
|
129
130
|
title: {
|
|
130
131
|
display: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin } from 'chart.js';
|
|
2
2
|
/**
|
|
3
3
|
* Chart border plugin config
|
|
4
4
|
*/
|
|
5
5
|
export declare const chartAreaBorderPlugin: {
|
|
6
6
|
id: string;
|
|
7
|
-
beforeDraw(chart:
|
|
7
|
+
beforeDraw(chart: any, _args: Plugin, options: any): void;
|
|
8
8
|
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ChartTypeRegistry, Plugin } from 'chart.js';
|
|
2
|
+
import { ICommonAnnotationsData, ICommonCustomLegend } from '../common.interface';
|
|
3
|
+
import { Position } from './enums';
|
|
4
|
+
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, legend: ILegend) => 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 {annotationsData[]} annotationsData
|
|
43
|
+
* @return {number[]|*[]}
|
|
44
|
+
*/
|
|
45
|
+
export declare const setAnnotations: (annotationsData: ICommonAnnotationsData[]) => number[];
|
|
46
|
+
/**
|
|
47
|
+
* @param {ICommonChartOptions} options - chart options object
|
|
48
|
+
* @return {{color: (string|undefined), display: boolean, text}|{}}
|
|
49
|
+
*/
|
|
50
|
+
export declare const getTitle: (options: IOptions) => {
|
|
51
|
+
display: boolean;
|
|
52
|
+
text: string | string[] | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
display?: undefined;
|
|
55
|
+
text?: undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* @function isVertical
|
|
59
|
+
* @param {'vertical'|'horizontal'|string} direction
|
|
60
|
+
* @return {boolean} returns true if chart direction is vertical
|
|
61
|
+
*/
|
|
62
|
+
export declare const isVertical: (direction: string) => boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @param {'x'|'y'} axisType
|
|
65
|
+
* @param {number} i - index
|
|
66
|
+
* @return {'top'|'bottom'|'left'|'right'|*}
|
|
67
|
+
*/
|
|
68
|
+
export declare const getAxisPosition: (axisType: string, i: number) => Position;
|
|
69
|
+
/**
|
|
70
|
+
* @param {chartStyling} chartStyling
|
|
71
|
+
* @param {Object} styles - styles imported form .less file
|
|
72
|
+
* @return {string} - class name
|
|
73
|
+
*/
|
|
74
|
+
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;
|
|
77
|
+
display: boolean | undefined;
|
|
78
|
+
align: string | undefined;
|
|
79
|
+
labels: {
|
|
80
|
+
boxHeight: number;
|
|
81
|
+
boxWidth: number | undefined;
|
|
82
|
+
usePointStyle: boolean | undefined;
|
|
83
|
+
};
|
|
84
|
+
onClick: (_e: any, legendItem: any) => void;
|
|
85
|
+
};
|
|
86
|
+
export declare const afterLabelCallback: (tooltipItem: Record<string, any>) => string;
|
|
87
|
+
export declare const getTooltipLabel: (tooltipItem: Record<string, any>, showLabelsInTooltips: boolean) => string;
|
|
88
|
+
export declare const getChartFileName: (axes: IAxis[]) => string;
|
|
89
|
+
export declare const setDefaultTheme: () => void;
|
|
90
|
+
export declare const isNilOrEmpty: (value: any) => boolean;
|
|
91
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chart,
|
|
1
|
+
import { Chart, ChartConfiguration, Plugin } from 'chart.js';
|
|
2
2
|
/**
|
|
3
3
|
* Gets an example custom legend plugin for use in storybook.
|
|
4
4
|
* @param {string} customLegendContainerID - the id of the div container to put the generated legend in
|
|
@@ -15,7 +15,7 @@ export interface IAxesOptions {
|
|
|
15
15
|
controlsAxesLabels: IAxisControlLabel[];
|
|
16
16
|
onUpdateAxes: (axes: IAxisState) => void;
|
|
17
17
|
onResetAxes: () => void;
|
|
18
|
-
depthType
|
|
18
|
+
depthType?: IDepthType | object;
|
|
19
19
|
close?: () => void;
|
|
20
20
|
}
|
|
21
21
|
export interface IOnEdit {
|
|
@@ -27,7 +27,7 @@ export interface IAxisFormState {
|
|
|
27
27
|
id: string;
|
|
28
28
|
min: number | string;
|
|
29
29
|
max: number | string;
|
|
30
|
-
unit
|
|
30
|
+
unit?: string | IUnitOptions;
|
|
31
31
|
}
|
|
32
32
|
export type IInitializeAxisFormState = IAxisFormState[];
|
|
33
33
|
export interface IError {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Dispatch, RefObject } from 'react';
|
|
1
|
+
import { Dispatch, ReactNode, RefObject } from 'react';
|
|
2
2
|
import { Chart } from 'chart.js';
|
|
3
3
|
import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
|
|
4
4
|
import { IState } from '../state/state.interfaces';
|
|
5
5
|
export interface IControls {
|
|
6
|
-
headerComponent?:
|
|
6
|
+
headerComponent?: ReactNode;
|
|
7
7
|
subheaderComponent?: Element;
|
|
8
8
|
table?: Element;
|
|
9
9
|
chartRef: RefObject<Chart>;
|
|
@@ -4,7 +4,7 @@ export interface IDragOptions {
|
|
|
4
4
|
panEnabled: boolean;
|
|
5
5
|
zoomEnabled: boolean;
|
|
6
6
|
enableDragPoints: boolean;
|
|
7
|
-
isDragDataAllowed
|
|
7
|
+
isDragDataAllowed?: boolean;
|
|
8
8
|
onToggleDragPoints: () => void;
|
|
9
9
|
onDisableDragOptions: () => void;
|
|
10
10
|
translations: Record<string, string>;
|
|
@@ -2,7 +2,7 @@ import { Dispatch, RefObject } from 'react';
|
|
|
2
2
|
import { Chart, ChartEvent } from 'chart.js';
|
|
3
3
|
import { ICommonHoveredItems } from '../../common/common.interface';
|
|
4
4
|
import { ILineChartDataset, ILineChartOptions } from '../line-chart.interface';
|
|
5
|
-
import { IState } from '../state/state.interfaces';
|
|
5
|
+
import { InitialState, IState } from '../state/state.interfaces';
|
|
6
6
|
interface IUseChartFunctions {
|
|
7
7
|
chartRef: RefObject<Chart>;
|
|
8
8
|
state: IState;
|
|
@@ -40,8 +40,6 @@ export declare const useChartFunctions: ({ chartRef, state, options, dispatch, g
|
|
|
40
40
|
}[];
|
|
41
41
|
updateAxesRangesFromChart: () => void;
|
|
42
42
|
onResetAxes: () => void;
|
|
43
|
-
onUpdateAxes: ({ axes }:
|
|
44
|
-
axes: any;
|
|
45
|
-
}) => void;
|
|
43
|
+
onUpdateAxes: ({ axes }: InitialState) => void;
|
|
46
44
|
};
|
|
47
45
|
export {};
|
|
@@ -31,7 +31,7 @@ export interface ILegend {
|
|
|
31
31
|
options: ILineChartOptions;
|
|
32
32
|
dispatch: Dispatch<any>;
|
|
33
33
|
generatedDatasets: ILineChartDataset[];
|
|
34
|
-
translations
|
|
34
|
+
translations?: Record<string, string>;
|
|
35
35
|
}
|
|
36
36
|
export interface ILegendPanel extends ILegend {
|
|
37
37
|
legendPosition: Position;
|
|
@@ -1,99 +1,2 @@
|
|
|
1
|
-
import { ILineChartProps } from './line-chart.interface';
|
|
2
|
-
|
|
3
|
-
export declare const getDefaultProps: (props: ILineChartProps) => {
|
|
4
|
-
persistenceId: string;
|
|
5
|
-
controlsPortalId: string;
|
|
6
|
-
testId: string | null;
|
|
7
|
-
data: {
|
|
8
|
-
datasets: import("./line-chart.interface").ILineChartDataset[];
|
|
9
|
-
} | undefined;
|
|
10
|
-
options: {
|
|
11
|
-
title: string | string[];
|
|
12
|
-
scales: import("../common/common.interface").ICommonScales;
|
|
13
|
-
axes: {
|
|
14
|
-
x: import("./line-chart.interface").ILineChartAxis<"bottom" | "top">[] | {}[];
|
|
15
|
-
y: import("./line-chart.interface").ILineChartAxis<"left" | "right">[] | {}[];
|
|
16
|
-
};
|
|
17
|
-
additionalAxesOptions: {
|
|
18
|
-
chartScaleType: "linear" | "logarithmic";
|
|
19
|
-
reverse: boolean;
|
|
20
|
-
beginAtZero: boolean;
|
|
21
|
-
stepSize: number | undefined;
|
|
22
|
-
suggestedMin: number | undefined;
|
|
23
|
-
suggestedMax: number | undefined;
|
|
24
|
-
range: import("./line-chart.interface").ILineRange | undefined;
|
|
25
|
-
autoAxisPadding: boolean;
|
|
26
|
-
};
|
|
27
|
-
chartStyling: {
|
|
28
|
-
width: string | number | undefined;
|
|
29
|
-
height: string | number | undefined;
|
|
30
|
-
maintainAspectRatio: boolean;
|
|
31
|
-
staticChartHeight: boolean;
|
|
32
|
-
performanceMode: boolean;
|
|
33
|
-
squareAspectRatio: number | boolean;
|
|
34
|
-
layoutPadding: string | number | {
|
|
35
|
-
top: number;
|
|
36
|
-
bottom: number;
|
|
37
|
-
left: number;
|
|
38
|
-
right: number;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
tooltip: {
|
|
42
|
-
tooltips: boolean;
|
|
43
|
-
showLabelsInTooltips: boolean;
|
|
44
|
-
hideSimulationName: boolean;
|
|
45
|
-
};
|
|
46
|
-
graph: {
|
|
47
|
-
lineTension: number;
|
|
48
|
-
spanGaps: boolean;
|
|
49
|
-
showDataLabels: boolean;
|
|
50
|
-
showMinorGridlines: boolean;
|
|
51
|
-
};
|
|
52
|
-
annotations: {
|
|
53
|
-
labelAnnotation: {
|
|
54
|
-
showLabel: boolean;
|
|
55
|
-
text: string | string[];
|
|
56
|
-
position: string;
|
|
57
|
-
fontSize: number;
|
|
58
|
-
xOffset: number;
|
|
59
|
-
yOffset: number;
|
|
60
|
-
maxWidth: number;
|
|
61
|
-
lineHeight: number;
|
|
62
|
-
};
|
|
63
|
-
showAnnotations: boolean;
|
|
64
|
-
controlAnnotation: boolean;
|
|
65
|
-
annotationsData: import("../common/common.interface").ICommonAnnotationsData[];
|
|
66
|
-
};
|
|
67
|
-
legend: {
|
|
68
|
-
display: boolean;
|
|
69
|
-
position: Position;
|
|
70
|
-
align: AlignOptions;
|
|
71
|
-
customLegend: import("../common/common.interface").ICommonCustomLegend<any>;
|
|
72
|
-
usePointStyle: boolean;
|
|
73
|
-
};
|
|
74
|
-
chartOptions: {
|
|
75
|
-
showPoints: boolean;
|
|
76
|
-
enableZoom: boolean;
|
|
77
|
-
enablePan: boolean;
|
|
78
|
-
showLine: boolean;
|
|
79
|
-
closeOnOutsideClick: boolean;
|
|
80
|
-
};
|
|
81
|
-
interactions: {
|
|
82
|
-
onLegendClick: ((text: string, hidden: boolean) => void) | undefined;
|
|
83
|
-
onHover: ((event?: import("chart.js").ChartEvent | undefined, datasetIndex?: number | undefined, index?: number | undefined, generatedDataset?: any[] | undefined) => void) | undefined;
|
|
84
|
-
onUnhover: ((event?: import("chart.js").ChartEvent | undefined, datasetIndex?: number | undefined, index?: number | undefined, generatedDataset?: any[] | undefined) => void) | undefined;
|
|
85
|
-
onAnimationComplete: (() => void) | undefined;
|
|
86
|
-
};
|
|
87
|
-
dragData: {
|
|
88
|
-
enableDragData: boolean;
|
|
89
|
-
showTooltip: boolean;
|
|
90
|
-
roundPoints: boolean;
|
|
91
|
-
dragX: boolean;
|
|
92
|
-
dragY: boolean;
|
|
93
|
-
onDragStart: (() => void) | undefined;
|
|
94
|
-
onDrag: (() => void) | undefined;
|
|
95
|
-
onDragEnd: (() => void) | undefined;
|
|
96
|
-
};
|
|
97
|
-
depthType: import("./line-chart.interface").IDepthType;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
1
|
+
import { ILineChartData, ILineChartProps } from './line-chart.interface';
|
|
2
|
+
export declare const getDefaultProps: (props: ILineChartProps) => ILineChartData;
|
|
@@ -39,7 +39,7 @@ export interface ILineChartAxis<PositionType> {
|
|
|
39
39
|
label: string;
|
|
40
40
|
position: PositionType;
|
|
41
41
|
color: string | string[];
|
|
42
|
-
unit
|
|
42
|
+
unit?: IUnitOptions;
|
|
43
43
|
}
|
|
44
44
|
export interface ILineChartAxes {
|
|
45
45
|
x: ILineChartAxis<'top' | 'bottom'>[];
|
|
@@ -52,7 +52,7 @@ export interface IDepthType {
|
|
|
52
52
|
setSelectedUnit: () => void;
|
|
53
53
|
}
|
|
54
54
|
export interface ILineChartStyling extends ICommonStyling {
|
|
55
|
-
squareAspectRatio?: number;
|
|
55
|
+
squareAspectRatio?: number | boolean;
|
|
56
56
|
layoutPadding?: string | number | {
|
|
57
57
|
top: number;
|
|
58
58
|
bottom: number;
|
|
@@ -80,7 +80,7 @@ export interface ILineChartOptions extends ICommonOptions {
|
|
|
80
80
|
chartOptions: ILChartOptions;
|
|
81
81
|
interactions: ILineInteractions;
|
|
82
82
|
dragData?: ICommonDragData;
|
|
83
|
-
depthType
|
|
83
|
+
depthType?: IDepthType | object;
|
|
84
84
|
}
|
|
85
85
|
export interface ILineChartDataset extends ICommonDataset {
|
|
86
86
|
lineTension?: number;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IState } from './state.interfaces';
|
|
2
|
+
import { ILineChartOptions } from '../line-chart.interface';
|
|
3
3
|
interface inputInitState {
|
|
4
|
-
options:
|
|
5
|
-
additionalAxesOptions: ILineChartAdditionalAxesOptions;
|
|
6
|
-
annotations: ICommonAnnotations;
|
|
7
|
-
axes: ILineChartAxes;
|
|
8
|
-
chartOptions: ILChartOptions;
|
|
9
|
-
legend: ILineLegend;
|
|
10
|
-
dragData: ICommonDragData;
|
|
11
|
-
};
|
|
4
|
+
options: ILineChartOptions;
|
|
12
5
|
persistenceId?: string;
|
|
13
6
|
}
|
|
14
7
|
/**
|
|
@@ -17,20 +10,5 @@ interface inputInitState {
|
|
|
17
10
|
@param {Object} options - The chart options.
|
|
18
11
|
@return {Object} The initial chart state.
|
|
19
12
|
*/
|
|
20
|
-
declare const initialState: ({ options, persistenceId }: inputInitState) =>
|
|
21
|
-
zoomEnabled: any;
|
|
22
|
-
panEnabled: any;
|
|
23
|
-
pointsEnabled: any;
|
|
24
|
-
lineEnabled: any;
|
|
25
|
-
legendEnabled: any;
|
|
26
|
-
axes: {
|
|
27
|
-
unit?: import("../line-chart.interface").IUnitOptions | undefined;
|
|
28
|
-
max?: number | undefined;
|
|
29
|
-
min?: number | undefined;
|
|
30
|
-
id: string;
|
|
31
|
-
}[];
|
|
32
|
-
showAnnotationLineIndex: number[];
|
|
33
|
-
showTable: boolean;
|
|
34
|
-
enableDragPoints: any;
|
|
35
|
-
};
|
|
13
|
+
declare const initialState: ({ options, persistenceId }: inputInitState) => IState;
|
|
36
14
|
export default initialState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const formatAxisLabelNumbers: (tickValue: number, ticks: Array<any
|
|
1
|
+
export declare const formatAxisLabelNumbers: (tickValue: number, ticks: Array<any>) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getGeneratedLabels: (chart: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oliasoft-open-source/charts-library",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "React Chart Library (based on Chart.js and react-chart-js-2)",
|
|
5
5
|
"homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
|
|
6
6
|
"resolutions": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-use": "^17.4.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@oliasoft-open-source/react-ui-library": "^3.
|
|
59
|
+
"@oliasoft-open-source/react-ui-library": "^3.11.9",
|
|
60
60
|
"@oliasoft-open-source/units": "^3.4.2",
|
|
61
61
|
"@storybook/addon-actions": "^7.0.18",
|
|
62
62
|
"@storybook/addon-docs": "^7.0.18",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"@storybook/react": "^7.0.18",
|
|
65
65
|
"@storybook/react-vite": "^7.0.18",
|
|
66
66
|
"@storybook/testing-library": "^0.2.2",
|
|
67
|
+
"@types/jest": "^29.5.6",
|
|
67
68
|
"@types/react": "^18.2.24",
|
|
68
69
|
"@typescript-eslint/parser": "^6.7.4",
|
|
69
70
|
"@vitejs/plugin-react-swc": "^3.3.2",
|