@acorex/charts 19.13.3 → 19.13.5
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/bar-chart/lib/bar-chart.component.d.ts +4 -7
- package/bar-chart/lib/bar-chart.type.d.ts +15 -7
- package/donut-chart/lib/donut-chart.component.d.ts +5 -0
- package/donut-chart/lib/donut-chart.type.d.ts +57 -0
- package/fesm2022/acorex-charts-bar-chart.mjs +92 -63
- package/fesm2022/acorex-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-chart-tooltip.mjs +3 -3
- package/fesm2022/acorex-charts-chart-tooltip.mjs.map +1 -1
- package/fesm2022/acorex-charts-donut-chart.mjs +123 -63
- package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-gauge-chart.mjs +269 -130
- package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-hierarchy-chart.mjs +17 -18
- package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-line-chart.mjs +197 -55
- package/fesm2022/acorex-charts-line-chart.mjs.map +1 -1
- package/gauge-chart/lib/gauge-chart.component.d.ts +41 -13
- package/gauge-chart/lib/gauge-chart.type.d.ts +36 -5
- package/hierarchy-chart/lib/hierarchy-chart.component.d.ts +2 -4
- package/hierarchy-chart/lib/hierarchy-chart.type.d.ts +43 -14
- package/line-chart/lib/line-chart.component.d.ts +1 -0
- package/line-chart/lib/line-chart.type.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AXChartTooltipData } from '@acorex/charts/chart-tooltip';
|
|
2
|
+
import { NXComponent } from '@acorex/components/common';
|
|
2
3
|
import { OnDestroy } from '@angular/core';
|
|
3
4
|
import { AXBarChartClickEvent, AXPBarChartData, AXPBarChartOption } from './bar-chart.type';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
@@ -10,7 +11,7 @@ export declare const AXBarChartColors: {
|
|
|
10
11
|
* Bar Chart Component
|
|
11
12
|
* Renders data as vertical bars with interactive hover effects and animations
|
|
12
13
|
*/
|
|
13
|
-
export declare class AXBarChartComponent implements OnDestroy {
|
|
14
|
+
export declare class AXBarChartComponent extends NXComponent implements OnDestroy {
|
|
14
15
|
/** Chart data input */
|
|
15
16
|
data: import("@angular/core").InputSignal<AXPBarChartData[]>;
|
|
16
17
|
/** Chart options input */
|
|
@@ -28,6 +29,7 @@ export declare class AXBarChartComponent implements OnDestroy {
|
|
|
28
29
|
private width;
|
|
29
30
|
private height;
|
|
30
31
|
private margin;
|
|
32
|
+
private _initialAnimationComplete;
|
|
31
33
|
private _tooltipVisible;
|
|
32
34
|
private _tooltipPosition;
|
|
33
35
|
private _tooltipData;
|
|
@@ -43,15 +45,10 @@ export declare class AXBarChartComponent implements OnDestroy {
|
|
|
43
45
|
protected effectiveOptions: import("@angular/core").Signal<{
|
|
44
46
|
width?: number;
|
|
45
47
|
height?: number;
|
|
46
|
-
margin?: {
|
|
47
|
-
top: number;
|
|
48
|
-
right: number;
|
|
49
|
-
bottom: number;
|
|
50
|
-
left: number;
|
|
51
|
-
};
|
|
52
48
|
showXAxis?: boolean;
|
|
53
49
|
showYAxis?: boolean;
|
|
54
50
|
showGrid?: boolean;
|
|
51
|
+
showDataLabels?: boolean;
|
|
55
52
|
xAxisLabel?: string;
|
|
56
53
|
yAxisLabel?: string;
|
|
57
54
|
showTooltip?: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NXNativeEvent } from '@acorex/components/common';
|
|
1
2
|
/**
|
|
2
3
|
* Bar chart data item interface
|
|
3
4
|
*/
|
|
@@ -12,23 +13,30 @@ export interface AXPBarChartData {
|
|
|
12
13
|
*/
|
|
13
14
|
export interface AXBarChartClickEvent {
|
|
14
15
|
item: AXPBarChartData;
|
|
15
|
-
event:
|
|
16
|
+
event: NXNativeEvent;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Bar chart options interface
|
|
20
|
+
*
|
|
21
|
+
* Component supports the following CSS custom properties (design tokens):
|
|
22
|
+
* - `--ax-comp-bar-chart-labels-color`: Color for axis labels in option (X/Y axis titles).
|
|
23
|
+
* Default: `--ax-sys-color-on-lightest-surface` (applied with 0.7 opacity where needed)
|
|
24
|
+
* - `--ax-comp-bar-chart-data-labels-color`: Color for data labels.
|
|
25
|
+
* Default: `--ax-sys-color-on-lightest-surface`
|
|
26
|
+
* - `--ax-comp-bar-chart-axis-color`: Color for X/Y axis lines.
|
|
27
|
+
* Default: `--ax-sys-color-on-lightest-surface`
|
|
28
|
+
* - `--ax-comp-bar-chart-grid-lines-color`: Color for grid lines.
|
|
29
|
+
* Default: `--ax-sys-color-on-lightest-surface` (applied with 0.2 opacity)
|
|
30
|
+
* - `--ax-comp-bar-chart-bg-color`: Background color for the chart.
|
|
31
|
+
* Default: `--ax-sys-color-lightest-surface`
|
|
19
32
|
*/
|
|
20
33
|
export interface AXPBarChartOption {
|
|
21
34
|
width?: number;
|
|
22
35
|
height?: number;
|
|
23
|
-
margin?: {
|
|
24
|
-
top: number;
|
|
25
|
-
right: number;
|
|
26
|
-
bottom: number;
|
|
27
|
-
left: number;
|
|
28
|
-
};
|
|
29
36
|
showXAxis?: boolean;
|
|
30
37
|
showYAxis?: boolean;
|
|
31
38
|
showGrid?: boolean;
|
|
39
|
+
showDataLabels?: boolean;
|
|
32
40
|
xAxisLabel?: string;
|
|
33
41
|
yAxisLabel?: string;
|
|
34
42
|
showTooltip?: boolean;
|
|
@@ -43,6 +43,7 @@ export declare class AXDonutChartComponent implements OnDestroy {
|
|
|
43
43
|
width?: number;
|
|
44
44
|
height?: number;
|
|
45
45
|
showTooltip?: boolean;
|
|
46
|
+
showDataLabels?: boolean;
|
|
46
47
|
donutWidth?: number;
|
|
47
48
|
cornerRadius?: number;
|
|
48
49
|
animationDuration?: number;
|
|
@@ -138,6 +139,10 @@ export declare class AXDonutChartComponent implements OnDestroy {
|
|
|
138
139
|
* Cleans up chart resources
|
|
139
140
|
*/
|
|
140
141
|
private cleanupChart;
|
|
142
|
+
/**
|
|
143
|
+
* Gets an accessibility label describing the donut chart for screen readers
|
|
144
|
+
*/
|
|
145
|
+
protected getAccessibilityLabel(): string;
|
|
141
146
|
static ɵfac: i0.ɵɵFactoryDeclaration<AXDonutChartComponent, never>;
|
|
142
147
|
static ɵcmp: i0.ɵɵ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>;
|
|
143
148
|
}
|
|
@@ -8,14 +8,71 @@ export interface AXPDonutChartData {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Configuration options for the donut chart
|
|
11
|
+
*
|
|
12
|
+
* ## Design Tokens
|
|
13
|
+
* The component supports the following CSS custom properties:
|
|
14
|
+
*
|
|
15
|
+
* ### `--ax-comp-donut-chart-bg-color`
|
|
16
|
+
* Background color for the chart area and separator lines between segments.
|
|
17
|
+
* Default: `var(--ax-sys-color-lightest-surface)`
|
|
18
|
+
* Usage: `rgb(var(--ax-comp-donut-chart-bg-color))`
|
|
19
|
+
*
|
|
20
|
+
* ### `--ax-comp-donut-chart-text-color`
|
|
21
|
+
* Text color for all labels, values, total count, and percentage indicators.
|
|
22
|
+
* Default: `var(--ax-sys-color-on-lightest-surface)`
|
|
23
|
+
* Usage: `rgb(var(--ax-comp-donut-chart-text-color))`
|
|
24
|
+
*
|
|
25
|
+
* ## Usage
|
|
26
|
+
* Override these tokens in your CSS to customize the chart's appearance:
|
|
27
|
+
* ```css
|
|
28
|
+
* ax-donut-chart {
|
|
29
|
+
* --ax-comp-donut-chart-bg-color: var(--your-custom-background);
|
|
30
|
+
* --ax-comp-donut-chart-text-color: var(--your-custom-text-color);
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
11
33
|
*/
|
|
12
34
|
export interface AXPDonutChartOption {
|
|
35
|
+
/**
|
|
36
|
+
* Width of the chart in pixels
|
|
37
|
+
* If not provided, will use container width
|
|
38
|
+
*/
|
|
13
39
|
width?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Height of the chart in pixels
|
|
42
|
+
* If not provided, will use container height
|
|
43
|
+
*/
|
|
14
44
|
height?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Whether to show tooltips on hover
|
|
47
|
+
* Default: true
|
|
48
|
+
*/
|
|
15
49
|
showTooltip?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to show percentage labels inside chart segments
|
|
52
|
+
* Labels will only appear on segments large enough to fit text
|
|
53
|
+
* Default: true
|
|
54
|
+
*/
|
|
55
|
+
showDataLabels?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Width of the donut ring as a percentage (10-90)
|
|
58
|
+
* Higher values create a thicker ring
|
|
59
|
+
* Default: 35
|
|
60
|
+
*/
|
|
16
61
|
donutWidth?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Radius for rounded corners on segments in pixels
|
|
64
|
+
* Default: 4
|
|
65
|
+
*/
|
|
17
66
|
cornerRadius?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Duration of animations in milliseconds
|
|
69
|
+
* Default: 800
|
|
70
|
+
*/
|
|
18
71
|
animationDuration?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Type of easing function for animations
|
|
74
|
+
* Default: 'cubic-out'
|
|
75
|
+
*/
|
|
19
76
|
animationEasing?: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'cubic' | 'cubic-in' | 'cubic-out' | 'cubic-in-out';
|
|
20
77
|
}
|
|
21
78
|
/**
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { AXChartTooltipComponent } from '@acorex/charts/chart-tooltip';
|
|
2
|
+
import { NXComponent } from '@acorex/components/common';
|
|
2
3
|
import { CommonModule } from '@angular/common';
|
|
3
4
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, inject, input, output, viewChild, signal, computed, afterNextRender, effect, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
5
|
+
import { InjectionToken, inject, input, output, viewChild, signal, computed, afterNextRender, effect, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
5
6
|
import { AX_GLOBAL_CONFIG } from '@acorex/core/config';
|
|
6
7
|
import { set } from 'lodash-es';
|
|
7
8
|
|
|
8
9
|
const AXBarChartDefaultConfig = {
|
|
9
|
-
margin: {
|
|
10
|
-
top: 20,
|
|
11
|
-
right: 20,
|
|
12
|
-
bottom: 30,
|
|
13
|
-
left: 40,
|
|
14
|
-
},
|
|
15
10
|
showXAxis: true,
|
|
16
11
|
showYAxis: true,
|
|
17
12
|
showGrid: true,
|
|
13
|
+
showDataLabels: true,
|
|
18
14
|
showTooltip: true,
|
|
19
15
|
barWidth: 80,
|
|
20
16
|
cornerRadius: 4,
|
|
@@ -61,7 +57,7 @@ const AXBarChartColors = {
|
|
|
61
57
|
* Bar Chart Component
|
|
62
58
|
* Renders data as vertical bars with interactive hover effects and animations
|
|
63
59
|
*/
|
|
64
|
-
class AXBarChartComponent {
|
|
60
|
+
class AXBarChartComponent extends NXComponent {
|
|
65
61
|
// Inputs
|
|
66
62
|
/** Chart data input */
|
|
67
63
|
data = input([]);
|
|
@@ -85,6 +81,8 @@ class AXBarChartComponent {
|
|
|
85
81
|
width;
|
|
86
82
|
height;
|
|
87
83
|
margin = { top: 20, right: 20, bottom: 30, left: 40 };
|
|
84
|
+
// Animation state
|
|
85
|
+
_initialAnimationComplete = signal(false);
|
|
88
86
|
// Tooltip state
|
|
89
87
|
_tooltipVisible = signal(false);
|
|
90
88
|
_tooltipPosition = signal({ x: 0, y: 0 });
|
|
@@ -111,6 +109,7 @@ class AXBarChartComponent {
|
|
|
111
109
|
};
|
|
112
110
|
});
|
|
113
111
|
constructor() {
|
|
112
|
+
super();
|
|
114
113
|
// Dynamically load D3 and initialize the chart when the component is ready
|
|
115
114
|
afterNextRender(() => {
|
|
116
115
|
this._initialized.set(true);
|
|
@@ -231,10 +230,10 @@ class AXBarChartComponent {
|
|
|
231
230
|
calculateMargins(options) {
|
|
232
231
|
// Start with default margins
|
|
233
232
|
this.margin = {
|
|
234
|
-
top:
|
|
235
|
-
right:
|
|
236
|
-
bottom:
|
|
237
|
-
left:
|
|
233
|
+
top: 20,
|
|
234
|
+
right: 20,
|
|
235
|
+
bottom: 30,
|
|
236
|
+
left: 40,
|
|
238
237
|
};
|
|
239
238
|
// Adjust margins if axis labels are present
|
|
240
239
|
if (options.xAxisLabel) {
|
|
@@ -294,7 +293,13 @@ class AXBarChartComponent {
|
|
|
294
293
|
.attr('transform', `translate(0,${this.height})`)
|
|
295
294
|
.call(this.d3.axisBottom(this.xScale));
|
|
296
295
|
// Style the axis text
|
|
297
|
-
this.xAxis
|
|
296
|
+
this.xAxis
|
|
297
|
+
.selectAll('text')
|
|
298
|
+
.style('font-size', '11px')
|
|
299
|
+
.style('font-weight', '400')
|
|
300
|
+
.style('fill', 'rgba(var(--ax-comp-bar-chart-labels-color), 0.7)');
|
|
301
|
+
// Style all lines in the x-axis (path, ticks)
|
|
302
|
+
this.xAxis.selectAll('line, path').style('stroke', 'rgb(var(--ax-comp-bar-chart-grid-lines-color))');
|
|
298
303
|
// Add X axis label if provided
|
|
299
304
|
if (options.xAxisLabel) {
|
|
300
305
|
const labelY = this.height + this.margin.bottom * 0.65;
|
|
@@ -307,7 +312,7 @@ class AXBarChartComponent {
|
|
|
307
312
|
.attr('y', labelY)
|
|
308
313
|
.style('font-size', '13px')
|
|
309
314
|
.style('font-weight', '500')
|
|
310
|
-
.style('fill', '
|
|
315
|
+
.style('fill', 'rgb(var(--ax-comp-bar-chart-axis-label-color))')
|
|
311
316
|
.text(options.xAxisLabel);
|
|
312
317
|
}
|
|
313
318
|
}
|
|
@@ -315,7 +320,13 @@ class AXBarChartComponent {
|
|
|
315
320
|
// Create Y axis
|
|
316
321
|
this.yAxis = axesGroup.append('g').attr('class', 'ax-bar-chart-axis-y').call(this.d3.axisLeft(this.yScale));
|
|
317
322
|
// Style the axis text
|
|
318
|
-
this.yAxis
|
|
323
|
+
this.yAxis
|
|
324
|
+
.selectAll('text')
|
|
325
|
+
.style('font-size', '11px')
|
|
326
|
+
.style('font-weight', '400')
|
|
327
|
+
.style('fill', 'rgba(var(--ax-comp-bar-chart-labels-color), 0.7)');
|
|
328
|
+
// Style all lines in the y-axis (path, ticks)
|
|
329
|
+
this.yAxis.selectAll('line, path').style('stroke', 'rgb(var(--ax-comp-bar-chart-grid-lines-color))');
|
|
319
330
|
// Add Y axis label if provided
|
|
320
331
|
if (options.yAxisLabel) {
|
|
321
332
|
const labelX = -this.height / 2;
|
|
@@ -330,7 +341,7 @@ class AXBarChartComponent {
|
|
|
330
341
|
.attr('y', labelY)
|
|
331
342
|
.style('font-size', '13px')
|
|
332
343
|
.style('font-weight', '500')
|
|
333
|
-
.style('fill', '
|
|
344
|
+
.style('fill', 'rgb(var(--ax-comp-bar-chart-axis-label-color))')
|
|
334
345
|
.text(options.yAxisLabel);
|
|
335
346
|
}
|
|
336
347
|
}
|
|
@@ -343,14 +354,19 @@ class AXBarChartComponent {
|
|
|
343
354
|
.axisLeft(this.yScale)
|
|
344
355
|
.tickSize(-this.width)
|
|
345
356
|
.tickFormat(() => ''))
|
|
346
|
-
.selectAll('
|
|
347
|
-
.style('
|
|
357
|
+
.selectAll('line')
|
|
358
|
+
.style('stroke', 'rgb(var(--ax-comp-bar-chart-grid-lines-color))')
|
|
359
|
+
.style('stroke-opacity', 0.2);
|
|
360
|
+
// Remove unneeded elements from grid
|
|
361
|
+
this.chart.select('.ax-bar-chart-grid').selectAll('path, text').remove();
|
|
348
362
|
}
|
|
349
363
|
}
|
|
350
364
|
/**
|
|
351
365
|
* Renders the bars with animations
|
|
352
366
|
*/
|
|
353
367
|
renderBars(data) {
|
|
368
|
+
// Reset animation state
|
|
369
|
+
this._initialAnimationComplete.set(false);
|
|
354
370
|
// Get corner radius from options
|
|
355
371
|
const radius = this.effectiveOptions().cornerRadius;
|
|
356
372
|
// Get animation options
|
|
@@ -377,52 +393,61 @@ class AXBarChartComponent {
|
|
|
377
393
|
.attr('rx', radius) // Rounded corners
|
|
378
394
|
.attr('ry', radius) // Rounded corners
|
|
379
395
|
.attr('fill', (d, i) => d.color || AXBarChartColors.getColor(i));
|
|
396
|
+
// Add data labels if they're enabled
|
|
397
|
+
if (this.effectiveOptions().showDataLabels !== false) {
|
|
398
|
+
barGroups
|
|
399
|
+
.append('text')
|
|
400
|
+
.attr('class', 'ax-bar-chart-data-label')
|
|
401
|
+
.attr('text-anchor', 'middle')
|
|
402
|
+
.attr('x', (d) => this.xScale(d.label) + this.xScale.bandwidth() / 2)
|
|
403
|
+
.attr('y', this.height) // Start from bottom for animation
|
|
404
|
+
.style('font-size', 'clamp(8px, 2vmin, 12px)')
|
|
405
|
+
.style('font-weight', '500')
|
|
406
|
+
.style('fill', 'rgb(var(--ax-comp-bar-chart-data-labels-color))')
|
|
407
|
+
.style('opacity', 0) // Start invisible for animation
|
|
408
|
+
.text((d) => d.value);
|
|
409
|
+
// Animate data labels
|
|
410
|
+
barGroups
|
|
411
|
+
.selectAll('.ax-bar-chart-data-label')
|
|
412
|
+
.transition()
|
|
413
|
+
.duration(animationDuration)
|
|
414
|
+
.delay((d, i) => i * 50 + 100) // Slightly delayed after bar animation
|
|
415
|
+
.attr('y', (d) => this.yScale(d.value) - 8) // Position above bar
|
|
416
|
+
.style('opacity', 1)
|
|
417
|
+
.ease(animationEasing);
|
|
418
|
+
}
|
|
380
419
|
// Set up event handlers on each group
|
|
381
420
|
barGroups
|
|
382
421
|
.on('mouseenter', (event, d) => {
|
|
422
|
+
// Only apply hover effects if initial animation is complete
|
|
423
|
+
if (!this._initialAnimationComplete())
|
|
424
|
+
return;
|
|
383
425
|
const barEl = this.d3.select(event.currentTarget).select('rect');
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const currentWidth = parseFloat(barEl.attr('width'));
|
|
387
|
-
const currentHeight = parseFloat(barEl.attr('height'));
|
|
388
|
-
// Calculate horizontal center point of the bar
|
|
389
|
-
const centerX = currentX + currentWidth / 2;
|
|
390
|
-
// Scale amount (5% larger)
|
|
391
|
-
const scaleX = 1.05;
|
|
392
|
-
const scaleY = 1.05;
|
|
393
|
-
// Calculate new dimensions with scaling
|
|
394
|
-
const newWidth = currentWidth * scaleX;
|
|
395
|
-
const newHeight = currentHeight * scaleY;
|
|
396
|
-
// Calculate new position:
|
|
397
|
-
// - Horizontally center-aligned
|
|
398
|
-
// - Vertically grow only upward from the bottom (X-axis)
|
|
399
|
-
const newX = centerX - newWidth / 2;
|
|
400
|
-
// The bottom of the bar stays at the same position (aligned with x-axis)
|
|
401
|
-
const newY = currentY - (newHeight - currentHeight);
|
|
402
|
-
// Apply the new position and size
|
|
403
|
-
barEl
|
|
404
|
-
.transition()
|
|
405
|
-
.duration(200)
|
|
406
|
-
.attr('x', newX)
|
|
407
|
-
.attr('y', newY)
|
|
408
|
-
.attr('width', newWidth)
|
|
409
|
-
.attr('height', newHeight);
|
|
426
|
+
// Standard hover effect - darken the bar slightly and add a subtle shadow
|
|
427
|
+
barEl.transition().duration(150).style('filter', 'brightness(0.9) drop-shadow(0 0 2px rgba(0,0,0,0.1))');
|
|
410
428
|
this.handleBarHover(event, d);
|
|
411
429
|
})
|
|
412
|
-
.on('mousemove', (event) =>
|
|
430
|
+
.on('mousemove', (event) => {
|
|
431
|
+
// Only update tooltip if initial animation is complete
|
|
432
|
+
if (this._initialAnimationComplete()) {
|
|
433
|
+
this.updateTooltipPosition(event);
|
|
434
|
+
}
|
|
435
|
+
})
|
|
413
436
|
.on('mouseleave', (event, d) => {
|
|
437
|
+
// Only apply hover effects if initial animation is complete
|
|
438
|
+
if (!this._initialAnimationComplete())
|
|
439
|
+
return;
|
|
414
440
|
const barEl = this.d3.select(event.currentTarget).select('rect');
|
|
415
|
-
//
|
|
416
|
-
barEl
|
|
417
|
-
.transition()
|
|
418
|
-
.duration(200)
|
|
419
|
-
.attr('x', (d) => this.xScale(d.label))
|
|
420
|
-
.attr('y', (d) => this.yScale(d.value))
|
|
421
|
-
.attr('width', this.xScale.bandwidth())
|
|
422
|
-
.attr('height', (d) => this.height - this.yScale(d.value));
|
|
441
|
+
// Remove hover effect
|
|
442
|
+
barEl.transition().duration(150).style('filter', null);
|
|
423
443
|
this._tooltipVisible.set(false);
|
|
424
444
|
})
|
|
425
|
-
.on('click', (event, d) =>
|
|
445
|
+
.on('click', (event, d) => {
|
|
446
|
+
// Only trigger click events if initial animation is complete
|
|
447
|
+
if (this._initialAnimationComplete()) {
|
|
448
|
+
this.handleBarClick(event, d);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
426
451
|
// Add animation
|
|
427
452
|
bars
|
|
428
453
|
.transition()
|
|
@@ -430,7 +455,12 @@ class AXBarChartComponent {
|
|
|
430
455
|
.delay((d, i) => i * 50) // Stagger each bar animation
|
|
431
456
|
.attr('y', (d) => this.yScale(d.value))
|
|
432
457
|
.attr('height', (d) => this.height - this.yScale(d.value))
|
|
433
|
-
.ease(animationEasing)
|
|
458
|
+
.ease(animationEasing) // Use the configured easing function
|
|
459
|
+
.end() // Wait for all animations to complete
|
|
460
|
+
.then(() => {
|
|
461
|
+
// Mark animation as complete to enable hover effects
|
|
462
|
+
this._initialAnimationComplete.set(true);
|
|
463
|
+
});
|
|
434
464
|
}
|
|
435
465
|
/**
|
|
436
466
|
* Gets the appropriate D3 easing function based on the option string
|
|
@@ -514,7 +544,7 @@ class AXBarChartComponent {
|
|
|
514
544
|
* Handles bar click event
|
|
515
545
|
*/
|
|
516
546
|
handleBarClick(event, datum) {
|
|
517
|
-
this.barClick.emit({ item: datum, event });
|
|
547
|
+
this.barClick.emit({ item: datum, event: { nativeEvent: event, sender: this } });
|
|
518
548
|
}
|
|
519
549
|
/**
|
|
520
550
|
* Shows a message when no data is available
|
|
@@ -530,13 +560,13 @@ class AXBarChartComponent {
|
|
|
530
560
|
.style('flex-direction', 'column')
|
|
531
561
|
.style('align-items', 'center')
|
|
532
562
|
.style('justify-content', 'center')
|
|
533
|
-
.style('text-align', 'center')
|
|
563
|
+
.style('text-align', 'center')
|
|
564
|
+
.style('background-color', 'rgb(var(--ax-comp-bar-chart-bg-color))');
|
|
534
565
|
// Add an icon
|
|
535
566
|
messageContainer
|
|
536
567
|
.append('div')
|
|
537
568
|
.attr('class', 'ax-bar-chart-no-data-icon')
|
|
538
569
|
.style('margin-bottom', '10px')
|
|
539
|
-
.style('color', 'var(--ax-text-muted, #999)')
|
|
540
570
|
.html('<i class="fa-light fa-chart-bar fa-2x"></i>');
|
|
541
571
|
// Add text message
|
|
542
572
|
messageContainer
|
|
@@ -544,15 +574,14 @@ class AXBarChartComponent {
|
|
|
544
574
|
.attr('class', 'ax-bar-chart-no-data-text')
|
|
545
575
|
.style('font-size', '16px')
|
|
546
576
|
.style('font-weight', '600')
|
|
547
|
-
.style('color', 'var(--ax-text-color, #333)')
|
|
548
577
|
.text('No data available');
|
|
549
578
|
}
|
|
550
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
551
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.
|
|
579
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXBarChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
580
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.10", type: AXBarChartComponent, isStandalone: true, selector: "ax-bar-chart", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick" }, viewQueries: [{ propertyName: "chartContainerEl", first: true, predicate: ["chartContainer"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-bar-chart\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["ax-bar-chart{display:block;width:100%;height:100%;min-height:200px;--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: var(--ax-sys-color-lightest-surface)}.ax-bar-chart{width:100%;height:100%;position:relative;display:flex;align-items:center;justify-content:center;border-radius:.5rem;overflow:hidden;color:rgb(var(--ax-sys-color-on-lightest-surface));background-color:rgb(var(--ax-comp-bar-chart-bg-color))}.ax-bar-chart svg{width:100%;height:100%;max-width:100%;max-height:100%;overflow:visible}.ax-bar-chart-no-data-message{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:1rem;width:100%;height:100%;color:rgb(var(--ax-sys-color-on-lightest-surface));background-color:rgb(var(--ax-comp-bar-chart-bg-color))}.ax-bar-chart-no-data-icon{margin-bottom:.75rem;color:rgba(var(--ax-sys-color-on-lightest-surface),.6)}.ax-bar-chart-no-data-text{font-weight:600;color:rgb(var(--ax-sys-color-on-lightest-surface))}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: AXChartTooltipComponent, selector: "ax-chart-tooltip", inputs: ["data", "position", "visible", "showPercentage", "style"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
552
581
|
}
|
|
553
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
582
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXBarChartComponent, decorators: [{
|
|
554
583
|
type: Component,
|
|
555
|
-
args: [{ selector: 'ax-bar-chart',
|
|
584
|
+
args: [{ selector: 'ax-bar-chart', encapsulation: ViewEncapsulation.None, imports: [CommonModule, AXChartTooltipComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"ax-bar-chart\" #chartContainer>\n <!-- Shared tooltip component -->\n <ax-chart-tooltip\n [visible]=\"tooltipVisible()\"\n [position]=\"tooltipPosition()\"\n [data]=\"tooltipData()\"\n [showPercentage]=\"true\"\n ></ax-chart-tooltip>\n</div>\n", styles: ["ax-bar-chart{display:block;width:100%;height:100%;min-height:200px;--ax-comp-bar-chart-axis-label-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-data-labels-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-grid-lines-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-bar-chart-bg-color: var(--ax-sys-color-lightest-surface)}.ax-bar-chart{width:100%;height:100%;position:relative;display:flex;align-items:center;justify-content:center;border-radius:.5rem;overflow:hidden;color:rgb(var(--ax-sys-color-on-lightest-surface));background-color:rgb(var(--ax-comp-bar-chart-bg-color))}.ax-bar-chart svg{width:100%;height:100%;max-width:100%;max-height:100%;overflow:visible}.ax-bar-chart-no-data-message{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:1rem;width:100%;height:100%;color:rgb(var(--ax-sys-color-on-lightest-surface));background-color:rgb(var(--ax-comp-bar-chart-bg-color))}.ax-bar-chart-no-data-icon{margin-bottom:.75rem;color:rgba(var(--ax-sys-color-on-lightest-surface),.6)}.ax-bar-chart-no-data-text{font-weight:600;color:rgb(var(--ax-sys-color-on-lightest-surface))}\n"] }]
|
|
556
585
|
}], ctorParameters: () => [] });
|
|
557
586
|
|
|
558
587
|
/**
|