@oliasoft-open-source/charts-library 8.0.6 → 9.0.0-beta-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,458 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { AxisType } from '../common/enums.js';
|
|
3
|
+
import type { DeepPartial, ICommonAnnotations, ICommonChartOptions, ICommonCustomLegend, ICommonData, ICommonDataset, ICommonDataValue, ICommonDragData, ICommonInteractions, ICommonLegend, ICommonOptions, ICommonScales, ICommonStyling, ICommonTooltip, TAxisPosition } from '../common/common.interface.js';
|
|
4
|
+
/** Initial LineChart rendering and interaction controls. */
|
|
5
|
+
export interface ILChartOptions extends ICommonChartOptions {
|
|
6
|
+
/** Whether to draw point markers. */
|
|
7
|
+
showPoints?: boolean;
|
|
8
|
+
/** Closes the LineChart controls panel when clicking outside it. Defaults to false. */
|
|
9
|
+
closeOnOutsideClick?: boolean;
|
|
10
|
+
/** Whether to draw connecting lines. */
|
|
11
|
+
showLine?: boolean;
|
|
12
|
+
/** Enables zooming when supported by the chart. */
|
|
13
|
+
enableZoom?: boolean;
|
|
14
|
+
/** Enables panning when supported by the chart. */
|
|
15
|
+
enablePan?: boolean;
|
|
16
|
+
/** Enables annotation dragging in the corresponding controls. */
|
|
17
|
+
enableDragAnnotation?: boolean;
|
|
18
|
+
/** Legacy control flag; use `dragData.enableDragData` to configure LineChart point dragging. */
|
|
19
|
+
enableDragPoints?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** LineChart interpolation, missing-value and grid rendering settings. */
|
|
22
|
+
export interface ILineChartGraph {
|
|
23
|
+
/** Line interpolation tension; zero produces straight segments. */
|
|
24
|
+
lineTension?: number;
|
|
25
|
+
/** Connects line segments across missing values. */
|
|
26
|
+
spanGaps?: boolean;
|
|
27
|
+
/** Draws labels on data elements. */
|
|
28
|
+
showDataLabels?: boolean;
|
|
29
|
+
/** Draws intermediate grid lines between the main ticks. */
|
|
30
|
+
showMinorGridlines?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* LineChart tooltip formatting and callback overrides, independent of axis placement.
|
|
34
|
+
* By default the title uses X and the DS row uses Y; `titleAxis` swaps these coordinate roles.
|
|
35
|
+
*/
|
|
36
|
+
export interface ILineChartTooltip extends ICommonTooltip {
|
|
37
|
+
/** Compatibility flag retained by LineChart; currently does not alter tooltip text. */
|
|
38
|
+
hideSimulationName?: boolean;
|
|
39
|
+
/** Allows scientific notation when formatting tooltip numbers. Defaults to true. */
|
|
40
|
+
scientificNotation?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Axis whose value and axis label appear in the default tooltip title.
|
|
43
|
+
* The other axis supplies the value beside the DS name. Does not move or reverse axes.
|
|
44
|
+
* Axis configuration is resolved from the hovered DS axis IDs (`x`, `x2`, `y`, `y2`, ...).
|
|
45
|
+
* Time and category values use formatted scale values rather than raw numeric coordinates.
|
|
46
|
+
* Custom title and label callbacks override their respective defaults independently.
|
|
47
|
+
* Update this option when swapping data coordinates if the same quantity should remain in the title.
|
|
48
|
+
* @defaultValue 'x'
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const tooltip: ILineChartTooltip = { titleAxis: 'y' };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
titleAxis?: `${AxisType}`;
|
|
55
|
+
}
|
|
56
|
+
/** Optional lower and upper bounds for one scale. */
|
|
57
|
+
export interface ILineChartRange {
|
|
58
|
+
/** Explicit lower bound in scale units. */
|
|
59
|
+
min?: number | string;
|
|
60
|
+
/** Explicit upper bound in scale units. */
|
|
61
|
+
max?: number | string;
|
|
62
|
+
}
|
|
63
|
+
/** LineChart bounds indexed by scale ID. */
|
|
64
|
+
export interface ILineRange {
|
|
65
|
+
[key: string]: ILineChartRange;
|
|
66
|
+
}
|
|
67
|
+
/** LineChart scale defaults and per-axis range overrides. */
|
|
68
|
+
export interface ILineChartAdditionalAxesOptions {
|
|
69
|
+
/** Scale family used when constructing axes. */
|
|
70
|
+
chartScaleType?: 'linear' | 'logarithmic' | 'time' | 'timeseries';
|
|
71
|
+
/** Reverses the Y scale direction. Does not change tooltip axis selection. */
|
|
72
|
+
reverse?: boolean;
|
|
73
|
+
/** Includes zero when determining automatic scale bounds. */
|
|
74
|
+
beginAtZero?: boolean;
|
|
75
|
+
/** Requested spacing between axis ticks, in scale units. */
|
|
76
|
+
stepSize?: number;
|
|
77
|
+
/** Suggested lower scale bound; data may extend beyond it. */
|
|
78
|
+
suggestedMin?: number;
|
|
79
|
+
/** Suggested upper scale bound; data may extend beyond it. */
|
|
80
|
+
suggestedMax?: number;
|
|
81
|
+
/** Per-axis bounds keyed by scale ID, such as `x`, `y`, or `y2`. */
|
|
82
|
+
range?: ILineRange;
|
|
83
|
+
/** Adds padding to automatically computed axis bounds. Defaults to false in LineChart. */
|
|
84
|
+
autoAxisPadding?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Consumer-owned unit selector configuration. Selecting a unit does not itself convert input data. */
|
|
87
|
+
export interface IUnitOptions {
|
|
88
|
+
/** Available unit identifiers shown in the selector. */
|
|
89
|
+
options: string[];
|
|
90
|
+
/** Currently selected unit identifier. */
|
|
91
|
+
selectedUnit: string;
|
|
92
|
+
/** Notifies the consumer when another unit is selected; the consumer owns the selection. */
|
|
93
|
+
setSelectedUnit: (value: string) => void;
|
|
94
|
+
}
|
|
95
|
+
/** One LineChart axis. Array order determines generated IDs (`x`, `x2`, ... or `y`, `y2`, ...). */
|
|
96
|
+
export interface ILineChartAxis<PositionType = TAxisPosition> {
|
|
97
|
+
/** Optional axis metadata; generated scale IDs currently follow the axis array order. */
|
|
98
|
+
id?: string;
|
|
99
|
+
/** Axis title, also appended to the default tooltip title when this is the selected title axis. */
|
|
100
|
+
label?: string;
|
|
101
|
+
/** Visual axis placement; does not affect tooltip coordinate roles. */
|
|
102
|
+
position?: PositionType;
|
|
103
|
+
/** Canvas/CSS colour used by this element. */
|
|
104
|
+
color?: string | string[];
|
|
105
|
+
/**
|
|
106
|
+
* Unit metadata or a consumer-owned unit selector. Does not convert DS coordinates.
|
|
107
|
+
* The default DS tooltip row uses this string or `selectedUnit` when non-empty, otherwise it extracts
|
|
108
|
+
* units from square brackets in the value-axis label. The title uses the title-axis label instead.
|
|
109
|
+
*/
|
|
110
|
+
unit?: IUnitOptions | string;
|
|
111
|
+
/** Requested spacing between axis ticks, in scale units. */
|
|
112
|
+
stepSize?: number;
|
|
113
|
+
/** Grid-line configuration for this axis. */
|
|
114
|
+
gridLines?: ILineChartGraph;
|
|
115
|
+
/** Explicit lower bound in scale units. */
|
|
116
|
+
min?: number | string;
|
|
117
|
+
/** Explicit upper bound in scale units. */
|
|
118
|
+
max?: number | string;
|
|
119
|
+
}
|
|
120
|
+
/** Ordered horizontal and vertical axis collections for LineChart. */
|
|
121
|
+
export interface ILineChartAxes {
|
|
122
|
+
/** Horizontal axis definitions in order. */
|
|
123
|
+
x: ILineChartAxis<'top' | 'bottom'>[];
|
|
124
|
+
/** Vertical axis definitions in order. */
|
|
125
|
+
y: ILineChartAxis<'left' | 'right'>[];
|
|
126
|
+
[key: string]: ILineChartAxis[];
|
|
127
|
+
}
|
|
128
|
+
/** Legacy selector type retained for source compatibility. */
|
|
129
|
+
export interface IDepthType {
|
|
130
|
+
/** Available selector values. */
|
|
131
|
+
options: string[];
|
|
132
|
+
/** Currently selected unit identifier. */
|
|
133
|
+
selectedUnit: string;
|
|
134
|
+
/** Notifies the consumer when another unit is selected; the consumer owns the selection. */
|
|
135
|
+
setSelectedUnit: (value: string) => void;
|
|
136
|
+
}
|
|
137
|
+
/** LineChart canvas size and chart-area padding. */
|
|
138
|
+
export interface ILineChartStyling extends ICommonStyling {
|
|
139
|
+
/** Requests a square chart layout; LineChart also accepts a numeric layout value. */
|
|
140
|
+
squareAspectRatio?: number | boolean;
|
|
141
|
+
/** Padding around the chart area, globally or per side. */
|
|
142
|
+
layoutPadding?: number | {
|
|
143
|
+
top: number;
|
|
144
|
+
bottom: number;
|
|
145
|
+
left: number;
|
|
146
|
+
right: number;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** LineChart pointer, legend and animation lifecycle callbacks. */
|
|
150
|
+
export interface ILineInteractions extends ICommonInteractions {
|
|
151
|
+
/** Called after a LineChart animation completes. */
|
|
152
|
+
onAnimationComplete?: () => void;
|
|
153
|
+
}
|
|
154
|
+
/** LineChart legend options, including external legend integration. */
|
|
155
|
+
export interface ILineLegend extends ICommonLegend {
|
|
156
|
+
/** Custom legend plugin and its target DOM container. */
|
|
157
|
+
customLegend?: ICommonCustomLegend<any>;
|
|
158
|
+
/** Uses point symbols in legend entries. */
|
|
159
|
+
usePointStyle?: boolean;
|
|
160
|
+
}
|
|
161
|
+
/** Resolved LineChart options. Consumers normally provide the partial {@link ILineChartOptionsInput}. */
|
|
162
|
+
export interface ILineChartOptions extends ICommonOptions {
|
|
163
|
+
/** Chart title; an array represents multiple lines. */
|
|
164
|
+
title?: string | string[];
|
|
165
|
+
/** Axis descriptions. Configure horizontal axes in `x` and vertical axes in `y`. */
|
|
166
|
+
axes: ILineChartAxes;
|
|
167
|
+
/** Chart.js scale configuration keyed by scale ID. */
|
|
168
|
+
scales: ICommonScales;
|
|
169
|
+
/** Scale behaviour, bounds and tick settings shared across the chart axes. */
|
|
170
|
+
additionalAxesOptions: ILineChartAdditionalAxesOptions;
|
|
171
|
+
/** Chart sizing and visual layout settings. */
|
|
172
|
+
chartStyling: ILineChartStyling;
|
|
173
|
+
/** Tooltip visibility, formatting and supported callbacks. */
|
|
174
|
+
tooltip: ILineChartTooltip;
|
|
175
|
+
/** Geometry, grid and data-label rendering options. */
|
|
176
|
+
graph: ILineChartGraph;
|
|
177
|
+
/** Annotation visibility, interaction and geometry configuration. */
|
|
178
|
+
annotations: ICommonAnnotations;
|
|
179
|
+
/** Legend visibility, placement and custom rendering options. */
|
|
180
|
+
legend: ILineLegend;
|
|
181
|
+
/** Initial interaction and rendering controls. */
|
|
182
|
+
chartOptions: ILChartOptions;
|
|
183
|
+
/** Callbacks for legend and pointer interactions. */
|
|
184
|
+
interactions: ILineInteractions;
|
|
185
|
+
/** Point-dragging options and lifecycle callbacks. */
|
|
186
|
+
dragData?: ICommonDragData;
|
|
187
|
+
/** Legacy selector configuration passed to the LineChart axes controls. */
|
|
188
|
+
depthType?: IDepthType | object;
|
|
189
|
+
}
|
|
190
|
+
/** Compatibility input for a LineChart axis; known fields are normalized before rendering. */
|
|
191
|
+
type ILooseLineAxis = Omit<DeepPartial<ILineChartAxis<string>>, 'gridLines'> & {
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
/** Requested spacing between axis ticks, in scale units. */
|
|
194
|
+
stepSize?: unknown;
|
|
195
|
+
/** Grid-line configuration for this axis. */
|
|
196
|
+
gridLines?: unknown;
|
|
197
|
+
};
|
|
198
|
+
/** Permissive annotation input normalized by LineChart. */
|
|
199
|
+
type ILooseLineAnnotation = {
|
|
200
|
+
[key: string]: unknown;
|
|
201
|
+
/** Identifier used to associate this configuration with its rendered element. */
|
|
202
|
+
id?: string;
|
|
203
|
+
/** Display text associated with this element. */
|
|
204
|
+
label?: string;
|
|
205
|
+
/** Canvas/CSS colour used by this element. */
|
|
206
|
+
color?: string;
|
|
207
|
+
/** Canvas colour used for the element outline. */
|
|
208
|
+
borderColor?: string;
|
|
209
|
+
/** Canvas fill colour; arrays provide per-element colours where supported. */
|
|
210
|
+
backgroundColor?: string;
|
|
211
|
+
/** Outline width in canvas pixels. */
|
|
212
|
+
borderWidth?: number;
|
|
213
|
+
/** Whether this element is visible. */
|
|
214
|
+
display?: boolean;
|
|
215
|
+
/** Whether this annotation may expand the scale bounds to remain visible. */
|
|
216
|
+
adjustScaleRange?: boolean;
|
|
217
|
+
/** Opacity multiplier between 0 (transparent) and 1 (opaque). */
|
|
218
|
+
opacity?: number;
|
|
219
|
+
/** Excludes this entry from the legend where supported. */
|
|
220
|
+
hideLegend?: boolean;
|
|
221
|
+
/** Pixel offset between the label and its associated geometry. */
|
|
222
|
+
labelOffsetPx?: number;
|
|
223
|
+
/** Axis on which `value` and `endValue` locate the annotation. */
|
|
224
|
+
annotationAxis?: string;
|
|
225
|
+
/** Chart or annotation kind. */
|
|
226
|
+
type?: string;
|
|
227
|
+
/** Numeric value or axis coordinate represented by this item. */
|
|
228
|
+
value?: number | string | null;
|
|
229
|
+
/** Lower X bound in scale units. */
|
|
230
|
+
xMin?: number | string | null;
|
|
231
|
+
/** Upper X bound in scale units. */
|
|
232
|
+
xMax?: number | string | null;
|
|
233
|
+
/** Lower Y bound in scale units. */
|
|
234
|
+
yMin?: number | string | null;
|
|
235
|
+
/** Upper Y bound in scale units. */
|
|
236
|
+
yMax?: number | string | null;
|
|
237
|
+
/** X coordinate in scale units. */
|
|
238
|
+
xValue?: number | string | null;
|
|
239
|
+
/** Y coordinate in scale units. */
|
|
240
|
+
yValue?: number | string | null;
|
|
241
|
+
/** Called when a drag starts. */
|
|
242
|
+
onDragStart?: (...args: unknown[]) => void;
|
|
243
|
+
/** Called as the dragged value or annotation position changes. */
|
|
244
|
+
onDrag?: (...args: unknown[]) => void;
|
|
245
|
+
/** Called when dragging ends. */
|
|
246
|
+
onDragEnd?: (...args: unknown[]) => void;
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Consumer-facing LineChart options with optional defaults and compatibility fields.
|
|
250
|
+
* Unknown fields are accepted for compatibility, not guaranteed to be forwarded to Chart.js.
|
|
251
|
+
*/
|
|
252
|
+
export type ILineChartOptionsInput = Omit<DeepPartial<ILineChartOptions>, 'title' | 'axes' | 'legend' | 'chartStyling' | 'interactions' | 'graph' | 'annotations' | 'additionalAxesOptions' | 'scales' | 'plugins'> & {
|
|
253
|
+
[key: string]: unknown;
|
|
254
|
+
/** Chart title; an array represents multiple lines. */
|
|
255
|
+
title?: unknown;
|
|
256
|
+
/** Legacy input accepted for compatibility; LineChart does not use it to swap axes or tooltip values. */
|
|
257
|
+
direction?: string;
|
|
258
|
+
/** Axis descriptions. Configure horizontal axes in `x` and vertical axes in `y`. */
|
|
259
|
+
axes?: {
|
|
260
|
+
/** Horizontal axis definitions in order. */
|
|
261
|
+
x?: ILooseLineAxis[];
|
|
262
|
+
/** Vertical axis definitions in order. */
|
|
263
|
+
y?: ILooseLineAxis[];
|
|
264
|
+
[key: string]: ILooseLineAxis[] | undefined;
|
|
265
|
+
};
|
|
266
|
+
/** Chart.js scale overrides keyed by generated scale ID (`x`, `x2`, `y`, `y2`, ...). */
|
|
267
|
+
scales?: Record<string, unknown>;
|
|
268
|
+
/** Compatibility input; not forwarded by the LineChart option normalizer. */
|
|
269
|
+
plugins?: Record<string, unknown>;
|
|
270
|
+
/** Legend visibility, placement and custom rendering options. */
|
|
271
|
+
legend?: Omit<DeepPartial<ILineLegend>, 'position' | 'align'> & {
|
|
272
|
+
/** Visual placement of this element. */
|
|
273
|
+
position?: string;
|
|
274
|
+
/** Alignment within the available layout space. */
|
|
275
|
+
align?: string;
|
|
276
|
+
[key: string]: unknown;
|
|
277
|
+
};
|
|
278
|
+
/** Chart sizing and visual layout settings. */
|
|
279
|
+
chartStyling?: DeepPartial<ILineChartStyling> & {
|
|
280
|
+
/** Compatibility input; not currently consumed by the chart option normalizers. */
|
|
281
|
+
hideControls?: boolean;
|
|
282
|
+
/** Compatibility input; not currently consumed by the chart option normalizers. */
|
|
283
|
+
minHeight?: number | string;
|
|
284
|
+
[key: string]: unknown;
|
|
285
|
+
};
|
|
286
|
+
/** Callbacks for legend and pointer interactions. */
|
|
287
|
+
interactions?: DeepPartial<ILineInteractions> & {
|
|
288
|
+
/** Compatibility interaction input; configure zoom through `chartOptions.enableZoom`. */
|
|
289
|
+
enableZoom?: boolean;
|
|
290
|
+
/** Compatibility interaction input; configure pan through `chartOptions.enablePan`. */
|
|
291
|
+
enablePan?: boolean;
|
|
292
|
+
[key: string]: unknown;
|
|
293
|
+
};
|
|
294
|
+
/** Geometry, grid and data-label rendering options. */
|
|
295
|
+
graph?: DeepPartial<ILineChartGraph> & {
|
|
296
|
+
/** Legacy graph-level input; configure tooltips through `options.tooltip` instead. */
|
|
297
|
+
tooltip?: unknown;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
};
|
|
300
|
+
/** Annotation visibility, interaction and geometry configuration. */
|
|
301
|
+
annotations?: (Omit<DeepPartial<ICommonAnnotations>, 'annotationsData'> & {
|
|
302
|
+
/** Annotation definitions in drawing order. */
|
|
303
|
+
annotationsData?: ILooseLineAnnotation[];
|
|
304
|
+
}) | ILooseLineAnnotation[] | null;
|
|
305
|
+
/** Scale behaviour, bounds and tick settings shared across the chart axes. */
|
|
306
|
+
additionalAxesOptions?: Omit<DeepPartial<ILineChartAdditionalAxesOptions>, 'chartScaleType'> & {
|
|
307
|
+
/** Scale family used when constructing axes. */
|
|
308
|
+
chartScaleType?: string;
|
|
309
|
+
/** Requested spacing between axis ticks, in scale units. */
|
|
310
|
+
stepSize?: unknown;
|
|
311
|
+
/** Per-axis bounds keyed by scale ID, such as `x`, `y`, or `y2`. */
|
|
312
|
+
range?: ILineRange | ILineChartRange | Record<string, ILineChartRange | undefined>;
|
|
313
|
+
} & Record<string, unknown>;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Consumer-facing LineChart configuration. Missing datasets and options receive component defaults.
|
|
317
|
+
* Use this type for standalone chart configuration objects.
|
|
318
|
+
*/
|
|
319
|
+
export interface ILineChartDataInput extends Omit<ILineChartData, 'data' | 'options'> {
|
|
320
|
+
/** Values rendered by the chart or DS. */
|
|
321
|
+
data?: Omit<DeepPartial<ILineChartData['data']>, 'datasets'> & {
|
|
322
|
+
/** DS definitions in rendering order. */
|
|
323
|
+
datasets?: Array<(DeepPartial<ILineChartDataset> & {
|
|
324
|
+
/** Line interpolation tension; zero produces straight segments. */
|
|
325
|
+
lineTension?: number | string;
|
|
326
|
+
/** Controls filling beneath or between lines. */
|
|
327
|
+
fill?: boolean | string | Record<string, unknown>;
|
|
328
|
+
/** Point marker shape. */
|
|
329
|
+
pointStyle?: unknown;
|
|
330
|
+
/** Legacy input accepted for compatibility; prefer `showPoints`. */
|
|
331
|
+
showPoint?: boolean;
|
|
332
|
+
/** Whether to draw point markers. */
|
|
333
|
+
showPoints?: boolean;
|
|
334
|
+
/** Legacy DS input accepted for compatibility; not a tooltip formatting option. */
|
|
335
|
+
lineHeight?: number;
|
|
336
|
+
/** Values rendered by the chart or DS. */
|
|
337
|
+
data?: Array<DeepPartial<ICommonDataValue> | null>;
|
|
338
|
+
[key: string]: unknown;
|
|
339
|
+
}) | object | null> | object;
|
|
340
|
+
};
|
|
341
|
+
/** Configuration for this chart or generated element. */
|
|
342
|
+
options?: ILineChartOptionsInput;
|
|
343
|
+
}
|
|
344
|
+
/** Input DS for LineChart. Axis IDs bind values and tooltip units to the corresponding axes. */
|
|
345
|
+
export interface ILineChartDataset extends ICommonDataset {
|
|
346
|
+
/** DS interpolation tension; overrides `options.graph.lineTension` when provided. */
|
|
347
|
+
lineTension?: number;
|
|
348
|
+
/** Fill colour of the point marker. */
|
|
349
|
+
pointBackgroundColor?: string;
|
|
350
|
+
/** Point marker radius in pixels. */
|
|
351
|
+
pointRadius?: number;
|
|
352
|
+
/** Point radius while hovered, in pixels. */
|
|
353
|
+
pointHoverRadius?: number;
|
|
354
|
+
/** Additional hit-test radius around a point, in pixels. */
|
|
355
|
+
pointHitRadius?: number;
|
|
356
|
+
/** Controls filling beneath or between lines. */
|
|
357
|
+
fill?: boolean;
|
|
358
|
+
/** Horizontal scale ID for this DS, such as `x` or `x2`. */
|
|
359
|
+
xAxisID?: string;
|
|
360
|
+
/** Vertical scale ID for this DS, such as `y` or `y2`. */
|
|
361
|
+
yAxisID?: string;
|
|
362
|
+
/** Legacy flag that clips the DS endpoints against the first axis bounds. */
|
|
363
|
+
formation?: boolean;
|
|
364
|
+
/** Groups DS entries for legend display. */
|
|
365
|
+
displayGroup?: string | number;
|
|
366
|
+
/** Point marker shape. */
|
|
367
|
+
pointStyle?: string;
|
|
368
|
+
}
|
|
369
|
+
/** Normalized LineChart configuration and control integration identifiers. */
|
|
370
|
+
export interface ILineChartData extends ICommonData {
|
|
371
|
+
/** Values rendered by the chart or DS. */
|
|
372
|
+
data?: {
|
|
373
|
+
/** DS definitions in rendering order. */
|
|
374
|
+
datasets: ILineChartDataset[];
|
|
375
|
+
};
|
|
376
|
+
/** Configuration for this chart or generated element. */
|
|
377
|
+
options: ILineChartOptions;
|
|
378
|
+
/** Key used by LineChart to persist chart settings; use distinct IDs for independent charts. */
|
|
379
|
+
persistenceId?: string;
|
|
380
|
+
/** ID of an existing DOM element in which chart controls should be rendered. */
|
|
381
|
+
controlsPortalId?: string;
|
|
382
|
+
}
|
|
383
|
+
/** Props accepted by the LineChart React component. */
|
|
384
|
+
export interface ILineChartProps {
|
|
385
|
+
/** Chart data and options. Omitted optional settings are resolved by the component defaults. */
|
|
386
|
+
chart: ILineChartDataInput;
|
|
387
|
+
/** React table content exposed through the LineChart controls. */
|
|
388
|
+
table?: ReactNode;
|
|
389
|
+
/** React content rendered in the LineChart header. */
|
|
390
|
+
headerComponent?: ReactNode;
|
|
391
|
+
/** React content rendered below the LineChart header. */
|
|
392
|
+
subheaderComponent?: ReactNode;
|
|
393
|
+
}
|
|
394
|
+
/** Backward-compatible configuration type alias. Prefer {@link ILineChartDataInput} for new configuration objects. */
|
|
395
|
+
export interface LineChart extends ILineChartDataInput {
|
|
396
|
+
}
|
|
397
|
+
/** DS produced by LineChart normalization, including generated annotation metadata. */
|
|
398
|
+
export interface IGeneratedLineChartDataset {
|
|
399
|
+
/** Display text associated with this element. */
|
|
400
|
+
label?: string;
|
|
401
|
+
/** Values rendered by the chart or DS. */
|
|
402
|
+
data: ICommonDataValue[];
|
|
403
|
+
/** Whether to draw connecting lines. */
|
|
404
|
+
showLine?: boolean;
|
|
405
|
+
/** Resolved interpolation tension for the generated DS. */
|
|
406
|
+
lineTension: number;
|
|
407
|
+
/** Connects line segments across missing values. */
|
|
408
|
+
spanGaps: boolean;
|
|
409
|
+
/** Outline width in canvas pixels. */
|
|
410
|
+
borderWidth: number;
|
|
411
|
+
/** Alternating dash and gap lengths in canvas pixels. */
|
|
412
|
+
borderDash: number[];
|
|
413
|
+
/** Canvas join style at line segment corners. */
|
|
414
|
+
borderJoinStyle: 'round' | 'bevel' | 'miter';
|
|
415
|
+
/** Canvas colour used for the element outline. */
|
|
416
|
+
borderColor: string;
|
|
417
|
+
/** Canvas fill colour; arrays provide per-element colours where supported. */
|
|
418
|
+
backgroundColor: string | string[];
|
|
419
|
+
/** Fill colour of the point marker. */
|
|
420
|
+
pointBackgroundColor: string;
|
|
421
|
+
/** Point marker radius in pixels. */
|
|
422
|
+
pointRadius: number;
|
|
423
|
+
/** Point radius while hovered, in pixels. */
|
|
424
|
+
pointHoverRadius: number;
|
|
425
|
+
/** Additional hit-test radius around a point, in pixels. */
|
|
426
|
+
pointHitRadius: number;
|
|
427
|
+
/** Marks a generated DS as annotation data rather than plotted input data. */
|
|
428
|
+
isAnnotation?: boolean;
|
|
429
|
+
/** Shape identifier retained for the generated annotation DS. */
|
|
430
|
+
annotationType?: string;
|
|
431
|
+
/** Index of the source annotation in the annotation collection. */
|
|
432
|
+
annotationIndex?: number;
|
|
433
|
+
/** Text retained for the generated annotation DS. */
|
|
434
|
+
annotationLabel?: string;
|
|
435
|
+
/** Fill colour retained for the generated annotation DS. */
|
|
436
|
+
annotationBackgroundColor?: string;
|
|
437
|
+
/** Point fill retained for the generated annotation DS. */
|
|
438
|
+
annotationPointBackgroundColor?: string;
|
|
439
|
+
/** Outline colour retained for the generated annotation DS. */
|
|
440
|
+
annotationBorderColor?: string;
|
|
441
|
+
/** Outline dash pattern retained for the generated annotation DS. */
|
|
442
|
+
annotationBorderDash?: number[];
|
|
443
|
+
/** Outline width retained for the generated annotation DS. */
|
|
444
|
+
annotationBorderWidth?: number;
|
|
445
|
+
/** Groups DS entries for legend display. */
|
|
446
|
+
displayGroup?: string | number;
|
|
447
|
+
/** Excludes this entry from the legend where supported. */
|
|
448
|
+
hideLegend?: boolean;
|
|
449
|
+
/** Point marker shape. */
|
|
450
|
+
pointStyle?: string;
|
|
451
|
+
/** Horizontal scale ID for this DS, such as `x` or `x2`. */
|
|
452
|
+
xAxisID?: string;
|
|
453
|
+
/** Vertical scale ID for this DS, such as `y` or `y2`. */
|
|
454
|
+
yAxisID?: string;
|
|
455
|
+
}
|
|
456
|
+
/** Generated LineChart DS collection. */
|
|
457
|
+
export type TGeneratedLineChartDatasets = IGeneratedLineChartDataset[];
|
|
458
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ChartType, Plugin } from 'chart.js';
|
|
2
|
+
import { TCalloutConnector } from './helpers';
|
|
3
|
+
declare module 'chart.js' {
|
|
4
|
+
interface PluginOptionsByType<TType extends ChartType> {
|
|
5
|
+
calloutConnectorPlugin?: {
|
|
6
|
+
enableCalloutAnnotation?: boolean;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const calloutConnectorPlugin: Plugin;
|
|
11
|
+
export type { TCalloutConnector };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type TCalloutConnector = {
|
|
2
|
+
enabled?: boolean | ((context: {
|
|
3
|
+
chart: any;
|
|
4
|
+
labelEl?: TAnnotationLike;
|
|
5
|
+
fromEl?: TAnnotationLike;
|
|
6
|
+
option?: any;
|
|
7
|
+
}) => boolean);
|
|
8
|
+
fromId: string;
|
|
9
|
+
strokeStyle?: string;
|
|
10
|
+
lineWidth?: number;
|
|
11
|
+
lineDash?: number[];
|
|
12
|
+
startOffset?: number;
|
|
13
|
+
endOffset?: number;
|
|
14
|
+
anchor?: {
|
|
15
|
+
position?: string;
|
|
16
|
+
xAdjust?: number;
|
|
17
|
+
yAdjust?: number;
|
|
18
|
+
labelOffsetPx?: number;
|
|
19
|
+
tickSize?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type TAnnotationLike = {
|
|
23
|
+
centerX: number;
|
|
24
|
+
centerY: number;
|
|
25
|
+
width?: number;
|
|
26
|
+
height?: number;
|
|
27
|
+
options?: {
|
|
28
|
+
display: boolean;
|
|
29
|
+
radius?: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type TConnectorPoints = {
|
|
33
|
+
startX: number;
|
|
34
|
+
startY: number;
|
|
35
|
+
endX: number;
|
|
36
|
+
endY: number;
|
|
37
|
+
tickStartX: number;
|
|
38
|
+
tickStartY: number;
|
|
39
|
+
tickEndX: number;
|
|
40
|
+
tickEndY: number;
|
|
41
|
+
};
|
|
42
|
+
export declare const computeConnectorPoints: (fromEl: TAnnotationLike, labelEl: TAnnotationLike, connector: TCalloutConnector) => TConnectorPoints;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Chart, ChartConfiguration, Plugin } from 'chart.js';
|
|
2
|
+
import { Position } from '../../common/enums.js';
|
|
3
|
+
interface CustomChartConfiguration extends ChartConfiguration {
|
|
4
|
+
showLabel?: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
fontSize: number;
|
|
7
|
+
xOffset: number;
|
|
8
|
+
yOffset: number;
|
|
9
|
+
lineHeight: number;
|
|
10
|
+
maxWidth: number;
|
|
11
|
+
position: Position;
|
|
12
|
+
}
|
|
13
|
+
export declare const chartAreaTextPlugin: {
|
|
14
|
+
id: string;
|
|
15
|
+
beforeDraw: (chart: Chart, _args: Plugin, options: CustomChartConfiguration) => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Chart, Scale } from 'chart.js';
|
|
2
|
+
export declare const getLargestMajorTickWidth: (majorTickPositions: number[]) => number;
|
|
3
|
+
export declare const isValidPosition: (minorTickPosition: number, majorTickPositions: number[], scale: Scale) => boolean;
|
|
4
|
+
export declare const getMinorTickPositions: (majorTickPositions: number[], scale: Scale) => number[];
|
|
5
|
+
export declare const chartMinorGridlinesPlugin: {
|
|
6
|
+
id: string;
|
|
7
|
+
beforeDatasetsDraw: (chart: Chart) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Chart } from 'chart.js';
|
|
2
|
+
import { TLineMarkerTick, TLineMarkerDirection, TStickSide } from './types.js';
|
|
3
|
+
export type TDrawLineArgs = {
|
|
4
|
+
chart: Chart;
|
|
5
|
+
x1: number;
|
|
6
|
+
y1: number;
|
|
7
|
+
x2: number;
|
|
8
|
+
y2: number;
|
|
9
|
+
color: string;
|
|
10
|
+
opacity: number;
|
|
11
|
+
lineWidth: number;
|
|
12
|
+
lineDash: number[];
|
|
13
|
+
};
|
|
14
|
+
export declare const drawLineSegment: ({ chart, x1, y1, x2, y2, color, opacity, lineWidth, lineDash }: TDrawLineArgs) => {
|
|
15
|
+
x1: number;
|
|
16
|
+
y1: number;
|
|
17
|
+
x2: number;
|
|
18
|
+
y2: number;
|
|
19
|
+
};
|
|
20
|
+
export type TDrawTickArgs = {
|
|
21
|
+
ctx: CanvasRenderingContext2D;
|
|
22
|
+
chartArea: {
|
|
23
|
+
left: number;
|
|
24
|
+
right: number;
|
|
25
|
+
top: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
};
|
|
28
|
+
direction: TLineMarkerDirection;
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
side: TStickSide;
|
|
32
|
+
reverse?: boolean;
|
|
33
|
+
labelY?: number;
|
|
34
|
+
tick: TLineMarkerTick;
|
|
35
|
+
defaultColor: string;
|
|
36
|
+
defaultFont: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const drawTick: (args: TDrawTickArgs) => void;
|
|
39
|
+
export declare const getTickLabelHeight: (tick: TLineMarkerTick, defaultFont: string) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChartType, Plugin } from 'chart.js';
|
|
2
|
+
import { type TLineMarkersOptions } from './types';
|
|
3
|
+
declare module 'chart.js' {
|
|
4
|
+
interface PluginOptionsByType<TType extends ChartType> {
|
|
5
|
+
lineMarkersPlugin?: {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
} | TLineMarkersOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare const lineMarkersPlugin: Plugin;
|