@acorex/charts 0.0.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/README.md +72 -0
- package/bar-chart/README.md +3 -0
- package/bar-chart/index.d.ts +211 -0
- package/chart-legend/index.d.ts +104 -0
- package/chart-tooltip/README.md +3 -0
- package/chart-tooltip/index.d.ts +54 -0
- package/donut-chart/README.md +3 -0
- package/donut-chart/index.d.ts +251 -0
- package/fesm2022/acorex-charts-bar-chart.mjs +772 -0
- package/fesm2022/acorex-charts-bar-chart.mjs.map +1 -0
- package/fesm2022/acorex-charts-chart-legend.mjs +109 -0
- package/fesm2022/acorex-charts-chart-legend.mjs.map +1 -0
- package/fesm2022/acorex-charts-chart-tooltip.mjs +74 -0
- package/fesm2022/acorex-charts-chart-tooltip.mjs.map +1 -0
- package/fesm2022/acorex-charts-donut-chart.mjs +758 -0
- package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -0
- package/fesm2022/acorex-charts-gauge-chart.mjs +686 -0
- package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -0
- package/fesm2022/acorex-charts-hierarchy-chart.mjs +700 -0
- package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -0
- package/fesm2022/acorex-charts-line-chart.mjs +995 -0
- package/fesm2022/acorex-charts-line-chart.mjs.map +1 -0
- package/fesm2022/acorex-charts.mjs +41 -0
- package/fesm2022/acorex-charts.mjs.map +1 -0
- package/gauge-chart/README.md +3 -0
- package/gauge-chart/index.d.ts +218 -0
- package/hierarchy-chart/README.md +61 -0
- package/hierarchy-chart/index.d.ts +368 -0
- package/index.d.ts +14 -0
- package/line-chart/README.md +3 -0
- package/line-chart/index.d.ts +184 -0
- package/package.json +52 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import * as _acorex_cdk_common from '@acorex/cdk/common';
|
|
2
|
+
import { AXAnimationEasing } from '@acorex/cdk/common';
|
|
3
|
+
import * as d3 from 'd3';
|
|
4
|
+
import * as _angular_core from '@angular/core';
|
|
5
|
+
import { OnDestroy, InjectionToken } from '@angular/core';
|
|
6
|
+
import { AXChartLegendCompatible, AXChartLegendItem } from '@acorex/charts/chart-legend';
|
|
7
|
+
import { AXChartTooltipData } from '@acorex/charts/chart-tooltip';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single segment in the donut chart
|
|
11
|
+
*/
|
|
12
|
+
interface AXDonutChartData {
|
|
13
|
+
id: string;
|
|
14
|
+
value: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
tooltipLabel?: string;
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration options for the donut chart
|
|
21
|
+
*
|
|
22
|
+
* ## Design Tokens
|
|
23
|
+
* The component supports the following CSS custom properties:
|
|
24
|
+
*
|
|
25
|
+
* ### `--ax-comp-donut-chart-bg-color`
|
|
26
|
+
* Background color for the chart area and separator lines between segments.
|
|
27
|
+
* Default: `var(--ax-sys-color-lightest-surface)`
|
|
28
|
+
* Usage: `rgb(var(--ax-comp-donut-chart-bg-color))`
|
|
29
|
+
*
|
|
30
|
+
* ### `--ax-comp-donut-chart-text-color`
|
|
31
|
+
* Text color for all labels, values, total count, and percentage indicators.
|
|
32
|
+
* Default: `var(--ax-sys-color-on-lightest-surface)`
|
|
33
|
+
* Usage: `rgb(var(--ax-comp-donut-chart-text-color))`
|
|
34
|
+
*
|
|
35
|
+
* ## Usage
|
|
36
|
+
* Override these tokens in your CSS to customize the chart's appearance:
|
|
37
|
+
* ```css
|
|
38
|
+
* ax-donut-chart {
|
|
39
|
+
* --ax-comp-donut-chart-bg-color: var(--your-custom-background);
|
|
40
|
+
* --ax-comp-donut-chart-text-color: var(--your-custom-text-color);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
interface AXDonutChartOption {
|
|
45
|
+
/**
|
|
46
|
+
* Width of the chart in pixels
|
|
47
|
+
* If not provided, will use container width
|
|
48
|
+
*/
|
|
49
|
+
width?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Height of the chart in pixels
|
|
52
|
+
* If not provided, will use container height
|
|
53
|
+
*/
|
|
54
|
+
height?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Label for the total value
|
|
57
|
+
* Default: 'Total'
|
|
58
|
+
*/
|
|
59
|
+
totalLabel?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to show tooltips on hover
|
|
62
|
+
* Default: true
|
|
63
|
+
*/
|
|
64
|
+
showTooltip?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to show percentage labels inside chart segments
|
|
67
|
+
* Labels will only appear on segments large enough to fit text
|
|
68
|
+
* Default: true
|
|
69
|
+
*/
|
|
70
|
+
showDataLabels?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Width of the donut ring as a percentage (10-90)
|
|
73
|
+
* Higher values create a thicker ring
|
|
74
|
+
* Default: 35
|
|
75
|
+
*/
|
|
76
|
+
donutWidth?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Radius for rounded corners on segments in pixels
|
|
79
|
+
* Default: 4
|
|
80
|
+
*/
|
|
81
|
+
cornerRadius?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Duration of animations in milliseconds
|
|
84
|
+
* Default: 800
|
|
85
|
+
*/
|
|
86
|
+
animationDuration?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Type of easing function for animations
|
|
89
|
+
* Default: 'cubic-out'
|
|
90
|
+
*/
|
|
91
|
+
animationEasing?: AXAnimationEasing;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Data structure provided to the chart component
|
|
95
|
+
* Can be an array of AXPDonutChartData directly
|
|
96
|
+
*/
|
|
97
|
+
type AXDonutChartValue = AXDonutChartData[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Donut Chart Component
|
|
101
|
+
* Displays data in a circular donut chart with interactive segments
|
|
102
|
+
*/
|
|
103
|
+
declare class AXDonutChartComponent implements OnDestroy, AXChartLegendCompatible {
|
|
104
|
+
#private;
|
|
105
|
+
private cdr;
|
|
106
|
+
/** Chart data input */
|
|
107
|
+
data: _angular_core.InputSignal<AXDonutChartValue>;
|
|
108
|
+
/** Chart options input */
|
|
109
|
+
options: _angular_core.InputSignal<AXDonutChartOption>;
|
|
110
|
+
/** Emitted when a segment is clicked */
|
|
111
|
+
segmentClick: _angular_core.OutputEmitterRef<AXDonutChartData>;
|
|
112
|
+
/** Emitted when a segment has mouse hover
|
|
113
|
+
* Can be used by external elements to highlight this segment
|
|
114
|
+
*/
|
|
115
|
+
segmentHover: _angular_core.OutputEmitterRef<AXDonutChartData>;
|
|
116
|
+
private readonly chartContainerEl;
|
|
117
|
+
protected d3: typeof d3;
|
|
118
|
+
private svg;
|
|
119
|
+
private pieData;
|
|
120
|
+
private hiddenSegments;
|
|
121
|
+
private _initialized;
|
|
122
|
+
private _rendered;
|
|
123
|
+
private _isInitialAnimating;
|
|
124
|
+
private _tooltipVisible;
|
|
125
|
+
private _tooltipPosition;
|
|
126
|
+
private _tooltipData;
|
|
127
|
+
protected tooltipVisible: _angular_core.Signal<boolean>;
|
|
128
|
+
protected tooltipPosition: _angular_core.Signal<{
|
|
129
|
+
x: number;
|
|
130
|
+
y: number;
|
|
131
|
+
}>;
|
|
132
|
+
protected tooltipData: _angular_core.Signal<AXChartTooltipData>;
|
|
133
|
+
private configToken;
|
|
134
|
+
private chartColors;
|
|
135
|
+
protected effectiveOptions: _angular_core.Signal<{
|
|
136
|
+
width?: number;
|
|
137
|
+
height?: number;
|
|
138
|
+
totalLabel?: string;
|
|
139
|
+
showTooltip?: boolean;
|
|
140
|
+
showDataLabels?: boolean;
|
|
141
|
+
donutWidth?: number;
|
|
142
|
+
cornerRadius?: number;
|
|
143
|
+
animationDuration?: number;
|
|
144
|
+
animationEasing?: _acorex_cdk_common.AXAnimationEasing;
|
|
145
|
+
}>;
|
|
146
|
+
protected chartDataArray: _angular_core.Signal<AXDonutChartData[]>;
|
|
147
|
+
protected getColor(index: number): string;
|
|
148
|
+
protected isSegmentHidden(id: string): boolean;
|
|
149
|
+
constructor();
|
|
150
|
+
/**
|
|
151
|
+
* Highlights a specific segment by ID
|
|
152
|
+
* @param id The segment ID to highlight, or null to clear highlight
|
|
153
|
+
*/
|
|
154
|
+
highlightSegment(id: string | null): void;
|
|
155
|
+
/**
|
|
156
|
+
* Toggles visibility of a segment by ID
|
|
157
|
+
* @param id Segment ID to toggle
|
|
158
|
+
* @returns New visibility state (true = visible, false = hidden)
|
|
159
|
+
*/
|
|
160
|
+
toggleSegment(id: string): boolean;
|
|
161
|
+
ngOnDestroy(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Loads D3.js dynamically
|
|
164
|
+
*/
|
|
165
|
+
protected loadD3(): Promise<void>;
|
|
166
|
+
protected onSegmentClick(item: AXDonutChartData): void;
|
|
167
|
+
/**
|
|
168
|
+
* Creates the donut chart
|
|
169
|
+
*/
|
|
170
|
+
protected createChart(): void;
|
|
171
|
+
/**
|
|
172
|
+
* Updates the chart with new data
|
|
173
|
+
*/
|
|
174
|
+
protected updateChart(): void;
|
|
175
|
+
/**
|
|
176
|
+
* Clears the chart container
|
|
177
|
+
*/
|
|
178
|
+
private clearChart;
|
|
179
|
+
/**
|
|
180
|
+
* Shows a message when no data is available
|
|
181
|
+
*/
|
|
182
|
+
private showNoDataMessage;
|
|
183
|
+
/**
|
|
184
|
+
* Shows a message when all segments are hidden
|
|
185
|
+
*/
|
|
186
|
+
private showAllSegmentsHiddenMessage;
|
|
187
|
+
/**
|
|
188
|
+
* Setups chart dimensions based on container and options
|
|
189
|
+
*/
|
|
190
|
+
private setupDimensions;
|
|
191
|
+
/**
|
|
192
|
+
* Renders the donut chart with visible data
|
|
193
|
+
*/
|
|
194
|
+
private renderDonutChart;
|
|
195
|
+
/**
|
|
196
|
+
* Create SVG element with filter definitions for shadows
|
|
197
|
+
*/
|
|
198
|
+
private createSvgWithFilters;
|
|
199
|
+
/**
|
|
200
|
+
* Create and render the donut segments with animations
|
|
201
|
+
*/
|
|
202
|
+
private createDonutSegments;
|
|
203
|
+
/**
|
|
204
|
+
* Gets the appropriate D3 easing function based on the option string
|
|
205
|
+
*/
|
|
206
|
+
private getEasingFunction;
|
|
207
|
+
/**
|
|
208
|
+
* Handle hover effects on a segment
|
|
209
|
+
*/
|
|
210
|
+
private handleSliceHover;
|
|
211
|
+
/**
|
|
212
|
+
* Handles mouse leave from segments
|
|
213
|
+
*/
|
|
214
|
+
private handleSegmentLeave;
|
|
215
|
+
/**
|
|
216
|
+
* Updates tooltip position
|
|
217
|
+
* Ensures the tooltip is visible by adjusting position when near edges
|
|
218
|
+
*/
|
|
219
|
+
private updateTooltipPosition;
|
|
220
|
+
/**
|
|
221
|
+
* Adds center display with total value
|
|
222
|
+
*/
|
|
223
|
+
private addCenterDisplay;
|
|
224
|
+
/**
|
|
225
|
+
* Handles chart rendering errors
|
|
226
|
+
*/
|
|
227
|
+
private handleChartError;
|
|
228
|
+
/**
|
|
229
|
+
* Cleans up chart resources
|
|
230
|
+
*/
|
|
231
|
+
private cleanupChart;
|
|
232
|
+
/**
|
|
233
|
+
* Gets an accessibility label describing the donut chart for screen readers
|
|
234
|
+
*/
|
|
235
|
+
protected getAccessibilityLabel(): string;
|
|
236
|
+
/**
|
|
237
|
+
* Returns the data items for the legend
|
|
238
|
+
* @implements AXChartLegendCompatible
|
|
239
|
+
*/
|
|
240
|
+
getLegendItems(): AXChartLegendItem[];
|
|
241
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXDonutChartComponent, never>;
|
|
242
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXDonutChartComponent, "ax-donut-chart", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "segmentClick": "segmentClick"; "segmentHover": "segmentHover"; }, never, never, true, never>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
declare const AXDonutChartDefaultConfig: AXDonutChartOption;
|
|
246
|
+
declare const AX_DONUT_CHART_CONFIG: InjectionToken<AXDonutChartOption>;
|
|
247
|
+
type PartialDonutChartConfig = Partial<AXDonutChartOption>;
|
|
248
|
+
declare function donutChartConfig(config?: PartialDonutChartConfig): AXDonutChartOption;
|
|
249
|
+
|
|
250
|
+
export { AXDonutChartComponent, AXDonutChartDefaultConfig, AX_DONUT_CHART_CONFIG, donutChartConfig };
|
|
251
|
+
export type { AXDonutChartData, AXDonutChartOption, AXDonutChartValue, PartialDonutChartConfig };
|