@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 ADDED
@@ -0,0 +1,72 @@
1
+ # AcoreX Charts Library
2
+
3
+ A collection of Angular chart components powered by D3.js.
4
+
5
+ ## Available Charts
6
+
7
+ - Bar Chart
8
+ - Line Chart
9
+ - Donut Chart
10
+ - Gauge Chart
11
+ - Hierarchy Chart
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @acorex/charts
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Import specific chart components in your Angular module:
22
+
23
+ ```typescript
24
+ import { AXBarChartComponent } from '@acorex/charts/bar-chart';
25
+ import { AXLineChartComponent } from '@acorex/charts/line-chart';
26
+ import { AXDonutChartComponent } from '@acorex/charts/donut-chart';
27
+ ```
28
+
29
+ Add the components to your templates:
30
+
31
+ ```html
32
+ <ax-bar-chart [data]="barData" [options]="barOptions"></ax-bar-chart>
33
+ <ax-line-chart [data]="lineData" [options]="lineOptions"></ax-line-chart>
34
+ <ax-donut-chart [data]="donutData" [options]="donutOptions"></ax-donut-chart>
35
+ ```
36
+
37
+ ## Documentation
38
+
39
+ For detailed documentation and examples, see the individual chart component README files.
40
+
41
+ # ACoreX
42
+
43
+ ACoreX is an UI framework based on angular. With over 50+ beautiful fully responsive and accessible components for everyone.
44
+
45
+ [![License](https://img.shields.io/npm/l/nx.svg?style=flat-square)]()
46
+
47
+ A few links to help you get started:
48
+
49
+ - [ACoreX: Documentation, Guides](https://acorexui.com)
50
+
51
+ <picture>
52
+ <source media="(prefers-color-scheme: dark)" srcset="https://acorexui.com/public/acorex-slang-dark.svg">
53
+ <img alt="Acorex - Design System, UI Framework, App Builder" src="https://acorexui.com/public/acorex-slang-dark.svg" width="100%">
54
+ </picture>
55
+
56
+ ## Team Leads
57
+
58
+ | Arash Oshnoudi | Ali Safari |
59
+ | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
60
+ | ![Arash Oshnoudi](https://gravatar.com/avatar/df151090660e3842ec1ff788bb5a650e939e45784f01513a9b9f8107311e4e78?size=180) | ![Ali Safari](https://gravatar.com/avatar/555280ee36f23bedcfcfec6e068d1a85d7e1fd14676ca07e05958fc762199def?size=180) |
61
+
62
+ ## Develop Team
63
+
64
+ | Reza Safari | Matin Givi | Shahin Kahrizi | Mohammad Parsaeifard | Mojtaba Erfan Rad |
65
+ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
66
+ | ![Reza Safari](https://gravatar.com/avatar/0d419926e9e86bbb4b47ca6ae3ca6a2cde30fb01a6ddedefb97d043a350d11f0?size=180) | ![Matin Givi](https://gravatar.com/avatar/9a477829fc2ecdbce20a26af33d24baf63d24f042a551af8147eef1c99d2315a?size=180) | ![Shahin Kahrizi](https://gravatar.com/avatar/e699eeae86920ea44f9dd18f8bb01b5f0d28cdbd816032c4387f1f036c5977c0?size=180) | ![Mohammad Parsaeifard](https://gravatar.com/avatar/c0d9a0143f2dbbcea46e037d12ccad8f0fdaaeeaeb5089c1ae4a0c4ad131df88?size=180) | ![Mojtaba Erfan Rad](https://2.gravatar.com/avatar/791cb5077cf66aaf4f89098f9eb459a0c49198cc81d55a9b344d2620a72295bc?size=180) |
67
+
68
+ ## Design Team
69
+
70
+ | Mohammad Hasanzade | Meysa Aghili |
71
+ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
72
+ | ![Mohammad Hasanzade](https://gravatar.com/avatar/ca346e55701bbf079140cb04edea9e3c?size=180) | ![Meysa Aghili](https://0.gravatar.com/avatar/bf607792c9fac9e5f4e53d141d331abd11fa56e56f42da8b69cf9ede2ffff289?size=180) |
@@ -0,0 +1,3 @@
1
+ # @acorex/charts/bar-chart
2
+
3
+ Secondary entry point of `@acorex/charts`. It can be used by importing from `@acorex/charts/bar-chart`.
@@ -0,0 +1,211 @@
1
+ import * as _acorex_cdk_common from '@acorex/cdk/common';
2
+ import { AXAnimationEasing, NXNativeEvent, NXComponent } 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
+ * Bar chart data item interface
11
+ */
12
+ interface AXBarChartData {
13
+ id: string;
14
+ label: string;
15
+ value: number;
16
+ tooltipLabel?: string;
17
+ color?: string;
18
+ }
19
+ /**
20
+ * Bar chart click event interface
21
+ */
22
+ interface AXBarChartClickEvent {
23
+ item: AXBarChartData;
24
+ event: NXNativeEvent;
25
+ }
26
+ /**
27
+ * Bar chart options interface
28
+ *
29
+ * Component supports the following CSS custom properties (design tokens):
30
+ * - `--ax-comp-bar-chart-labels-color`: Color for axis labels in option (X/Y axis titles).
31
+ * Default: `--ax-sys-color-on-lightest-surface` (applied with 0.7 opacity where needed)
32
+ * - `--ax-comp-bar-chart-data-labels-color`: Color for data labels.
33
+ * Default: `--ax-sys-color-on-lightest-surface`
34
+ * - `--ax-comp-bar-chart-axis-color`: Color for X/Y axis lines.
35
+ * Default: `--ax-sys-color-on-lightest-surface`
36
+ * - `--ax-comp-bar-chart-grid-lines-color`: Color for grid lines.
37
+ * Default: `--ax-sys-color-on-lightest-surface` (applied with 0.2 opacity)
38
+ * - `--ax-comp-bar-chart-bg-color`: Background color for the chart.
39
+ * Default: `--ax-sys-color-lightest-surface`
40
+ */
41
+ interface AXBarChartOption {
42
+ width?: number;
43
+ height?: number;
44
+ showXAxis?: boolean;
45
+ showYAxis?: boolean;
46
+ showGrid?: boolean;
47
+ showDataLabels?: boolean;
48
+ xAxisLabel?: string;
49
+ yAxisLabel?: string;
50
+ showTooltip?: boolean;
51
+ barWidth?: number;
52
+ cornerRadius?: number;
53
+ animationDuration?: number;
54
+ animationEasing?: AXAnimationEasing;
55
+ }
56
+ /**
57
+ * Bar chart data type returned by getValue()
58
+ * Represents an array of bar chart data items
59
+ */
60
+ type AXBarChartValue = AXBarChartData[];
61
+
62
+ /**
63
+ * Bar Chart Component
64
+ * Renders data as vertical bars with interactive hover effects and animations
65
+ */
66
+ declare class AXBarChartComponent extends NXComponent implements OnDestroy, AXChartLegendCompatible {
67
+ /** Chart data input */
68
+ data: _angular_core.InputSignal<AXBarChartData[]>;
69
+ /** Chart options input */
70
+ options: _angular_core.InputSignal<AXBarChartOption>;
71
+ /** Emitted when a bar is clicked */
72
+ barClick: _angular_core.OutputEmitterRef<AXBarChartClickEvent>;
73
+ private readonly chartContainerEl;
74
+ protected d3: typeof d3;
75
+ private svg;
76
+ private chart;
77
+ private xScale;
78
+ private yScale;
79
+ private xAxis;
80
+ private yAxis;
81
+ private width;
82
+ private height;
83
+ private margin;
84
+ private _initialAnimationComplete;
85
+ private _tooltipVisible;
86
+ private _tooltipPosition;
87
+ private _tooltipData;
88
+ private _initialized;
89
+ private _rendered;
90
+ protected tooltipVisible: _angular_core.Signal<boolean>;
91
+ protected tooltipPosition: _angular_core.Signal<{
92
+ x: number;
93
+ y: number;
94
+ }>;
95
+ protected tooltipData: _angular_core.Signal<AXChartTooltipData>;
96
+ private configToken;
97
+ private chartColors;
98
+ private platform;
99
+ protected effectiveOptions: _angular_core.Signal<{
100
+ width?: number;
101
+ height?: number;
102
+ showXAxis?: boolean;
103
+ showYAxis?: boolean;
104
+ showGrid?: boolean;
105
+ showDataLabels?: boolean;
106
+ xAxisLabel?: string;
107
+ yAxisLabel?: string;
108
+ showTooltip?: boolean;
109
+ barWidth?: number;
110
+ cornerRadius?: number;
111
+ animationDuration?: number;
112
+ animationEasing?: _acorex_cdk_common.AXAnimationEasing;
113
+ }>;
114
+ private hiddenBars;
115
+ constructor();
116
+ ngOnDestroy(): void;
117
+ /**
118
+ * Loads D3.js dynamically
119
+ */
120
+ protected loadD3(): Promise<void>;
121
+ /**
122
+ * Creates the bar chart SVG and renders all elements
123
+ */
124
+ protected createChart(): void;
125
+ /**
126
+ * Updates the chart when inputs change
127
+ */
128
+ protected updateChart(): void;
129
+ /**
130
+ * Cleans up chart resources
131
+ */
132
+ protected cleanupChart(): void;
133
+ /**
134
+ * Sets up chart dimensions and creates SVG with responsive attributes
135
+ */
136
+ private setupDimensions;
137
+ /**
138
+ * Calculates chart margins based on options
139
+ */
140
+ private calculateMargins;
141
+ /**
142
+ * Creates x and y scales for the chart
143
+ */
144
+ private setupScales;
145
+ /**
146
+ * Creates x and y axes with grid lines
147
+ */
148
+ private createAxes;
149
+ /**
150
+ * Renders the bars with animations
151
+ */
152
+ private renderBars;
153
+ /**
154
+ * Gets the appropriate D3 easing function based on the option string
155
+ */
156
+ private getEasingFunction;
157
+ /**
158
+ * Handles bar hover event and shows tooltip
159
+ */
160
+ private handleBarHover;
161
+ /**
162
+ * Updates tooltip position based on mouse coordinates
163
+ */
164
+ private updateTooltipPosition;
165
+ /**
166
+ * Handles bar click event
167
+ */
168
+ private handleBarClick;
169
+ /**
170
+ * Shows a message when no data is available
171
+ */
172
+ private showNoDataMessage;
173
+ /**
174
+ * Shows a message when all bars are hidden
175
+ */
176
+ private showAllBarsHiddenMessage;
177
+ /**
178
+ * Gets the color for a bar based on its index
179
+ */
180
+ protected getColor(index: number): string;
181
+ /**
182
+ * Checks if a bar is hidden
183
+ */
184
+ protected isBarHidden(id: string): boolean;
185
+ /**
186
+ * Implementation of AXChartLegendCompatible interface
187
+ * Returns legend items based on the chart data
188
+ */
189
+ getLegendItems(): AXChartLegendItem[];
190
+ /**
191
+ * Implementation of AXChartLegendCompatible interface
192
+ * Highlights a specific bar by ID
193
+ */
194
+ highlightSegment(id: string | null): void;
195
+ /**
196
+ * Implementation of AXChartLegendCompatible interface
197
+ * Toggles visibility of a bar by ID
198
+ * @returns New visibility state (true = visible, false = hidden)
199
+ */
200
+ toggleSegment(id: string): boolean;
201
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXBarChartComponent, never>;
202
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXBarChartComponent, "ax-bar-chart", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "barClick": "barClick"; }, never, never, true, never>;
203
+ }
204
+
205
+ declare const AXBarChartDefaultConfig: AXBarChartOption;
206
+ declare const AX_BAR_CHART_CONFIG: InjectionToken<AXBarChartOption>;
207
+ type PartialBarChartConfig = Partial<AXBarChartOption>;
208
+ declare function barChartConfig(config?: PartialBarChartConfig): AXBarChartOption;
209
+
210
+ export { AXBarChartComponent, AXBarChartDefaultConfig, AX_BAR_CHART_CONFIG, barChartConfig };
211
+ export type { AXBarChartClickEvent, AXBarChartData, AXBarChartOption, AXBarChartValue, PartialBarChartConfig };
@@ -0,0 +1,104 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ElementRef } from '@angular/core';
3
+
4
+ /**
5
+ * Defines a legend item
6
+ */
7
+ interface AXChartLegendItem {
8
+ id: string;
9
+ name: string;
10
+ value: number | string;
11
+ percentage?: number;
12
+ color?: string;
13
+ hidden?: boolean;
14
+ [key: string]: any;
15
+ }
16
+ /**
17
+ * Interface that chart components should implement to work with the legend
18
+ */
19
+ interface AXChartLegendCompatible {
20
+ /**
21
+ * Returns the data items for the legend
22
+ */
23
+ getLegendItems(): AXChartLegendItem[];
24
+ /**
25
+ * Highlights a specific segment by ID
26
+ */
27
+ highlightSegment(id: string | null): void;
28
+ /**
29
+ * Toggles visibility of a segment by ID
30
+ * @returns New visibility state (true = visible, false = hidden)
31
+ */
32
+ toggleSegment(id: string): boolean;
33
+ }
34
+ /**
35
+ * Legend configuration options
36
+ */
37
+ interface AXChartLegendOptions {
38
+ showValues?: boolean;
39
+ showPercentage?: boolean;
40
+ className?: string;
41
+ interactive?: boolean;
42
+ mode?: 'vertical' | 'horizontal';
43
+ }
44
+
45
+ declare class AXChartLegendComponent {
46
+ /**
47
+ * Chart component instance
48
+ * Must implement AXChartLegendCompatible interface
49
+ */
50
+ chart: _angular_core.InputSignal<AXChartLegendCompatible>;
51
+ /**
52
+ * Configuration options for the legend
53
+ */
54
+ options: _angular_core.InputSignal<AXChartLegendOptions>;
55
+ /**
56
+ * Event emitted when a legend item is clicked
57
+ * Returns the item that was clicked
58
+ */
59
+ itemClick: _angular_core.OutputEmitterRef<AXChartLegendItem>;
60
+ /**
61
+ * Event emitted when the mouse enters a legend item
62
+ */
63
+ itemMouseEnter: _angular_core.OutputEmitterRef<AXChartLegendItem>;
64
+ /**
65
+ * Event emitted when the mouse leaves a legend item
66
+ */
67
+ itemMouseLeave: _angular_core.OutputEmitterRef<AXChartLegendItem>;
68
+ /**
69
+ * Reference to legend container for measuring dimensions
70
+ */
71
+ legendContainer?: ElementRef<HTMLDivElement>;
72
+ protected showValues: _angular_core.Signal<boolean>;
73
+ protected showPercentage: _angular_core.Signal<boolean>;
74
+ protected containerClass: _angular_core.Signal<{
75
+ [x: string]: boolean;
76
+ 'ax-chart-legend': boolean;
77
+ }>;
78
+ protected isInteractive: _angular_core.Signal<boolean>;
79
+ protected displayItems: _angular_core.Signal<AXChartLegendItem[]>;
80
+ /**
81
+ * Handle clicks on legend items
82
+ */
83
+ protected onItemClick(item: AXChartLegendItem): void;
84
+ /**
85
+ * Handle mouse enter on legend items
86
+ */
87
+ protected onItemMouseEnter(item: AXChartLegendItem): void;
88
+ /**
89
+ * Handle mouse leave on legend items
90
+ */
91
+ protected onItemMouseLeave(item: AXChartLegendItem): void;
92
+ /**
93
+ * Get legend container dimensions
94
+ */
95
+ getDimensions(): {
96
+ width: number;
97
+ height: number;
98
+ };
99
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXChartLegendComponent, never>;
100
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXChartLegendComponent, "ax-chart-legend", never, { "chart": { "alias": "chart"; "required": true; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; }, { "itemClick": "itemClick"; "itemMouseEnter": "itemMouseEnter"; "itemMouseLeave": "itemMouseLeave"; }, never, never, true, never>;
101
+ }
102
+
103
+ export { AXChartLegendComponent };
104
+ export type { AXChartLegendCompatible, AXChartLegendItem, AXChartLegendOptions };
@@ -0,0 +1,3 @@
1
+ # Chart Tooltip
2
+
3
+ Tooltip component for displaying information on hover in chart components.
@@ -0,0 +1,54 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { ElementRef } from '@angular/core';
3
+
4
+ interface AXChartTooltipData {
5
+ title: string;
6
+ value: number | string;
7
+ percentage?: string;
8
+ color?: string;
9
+ [key: string]: any;
10
+ }
11
+
12
+ declare class AXChartTooltipComponent {
13
+ private ngZone;
14
+ data: _angular_core.InputSignal<AXChartTooltipData>;
15
+ position: _angular_core.InputSignal<{
16
+ x: number;
17
+ y: number;
18
+ }>;
19
+ visible: _angular_core.InputSignal<boolean>;
20
+ /**
21
+ * Whether to show the tooltip's percentage badge
22
+ */
23
+ showPercentage: _angular_core.InputSignal<boolean>;
24
+ /**
25
+ * Optional custom styling for the tooltip
26
+ */
27
+ style: _angular_core.InputSignal<{
28
+ [key: string]: string;
29
+ }>;
30
+ /**
31
+ * Reference to tooltip container for measuring dimensions
32
+ */
33
+ tooltipContainer?: ElementRef<HTMLDivElement>;
34
+ protected tooltipWidth: number;
35
+ protected tooltipHeight: number;
36
+ constructor();
37
+ /**
38
+ * Updates tooltip dimensions after it's rendered
39
+ */
40
+ protected updateTooltipDimensions(): void;
41
+ /**
42
+ * Get adjusted tooltip position
43
+ * Exposes properties for parent components to query tooltip dimensions
44
+ */
45
+ getDimensions(): {
46
+ width: number;
47
+ height: number;
48
+ };
49
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXChartTooltipComponent, never>;
50
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXChartTooltipComponent, "ax-chart-tooltip", never, { "data": { "alias": "data"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "visible": { "alias": "visible"; "required": false; "isSignal": true; }; "showPercentage": { "alias": "showPercentage"; "required": false; "isSignal": true; }; "style": { "alias": "style"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
51
+ }
52
+
53
+ export { AXChartTooltipComponent };
54
+ export type { AXChartTooltipData };
@@ -0,0 +1,3 @@
1
+ # @acorex/chart/donut-chart
2
+
3
+ Secondary entry point of `@acorex/chart`. It can be used by importing from `@acorex/chart/donut-chart`.