@acorex/charts 20.1.24 → 20.1.26
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/index.d.ts +36 -1
- package/chart-legend/index.d.ts +1 -1
- package/chart-tooltip/index.d.ts +11 -4
- package/donut-chart/index.d.ts +32 -1
- package/fesm2022/acorex-charts-bar-chart.mjs +345 -259
- package/fesm2022/acorex-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-chart-legend.mjs +12 -15
- package/fesm2022/acorex-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/acorex-charts-chart-tooltip.mjs +38 -13
- package/fesm2022/acorex-charts-chart-tooltip.mjs.map +1 -1
- package/fesm2022/acorex-charts-donut-chart.mjs +116 -93
- package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-gauge-chart.mjs +39 -31
- package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-hierarchy-chart.mjs +24 -7
- package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-line-chart.mjs +50 -25
- package/fesm2022/acorex-charts-line-chart.mjs.map +1 -1
- package/gauge-chart/index.d.ts +14 -1
- package/hierarchy-chart/index.d.ts +22 -1
- package/line-chart/index.d.ts +28 -1
- package/package.json +1 -1
|
@@ -13,6 +13,11 @@ const AXGaugeChartDefaultConfig = {
|
|
|
13
13
|
showTooltip: true,
|
|
14
14
|
animationDuration: 750,
|
|
15
15
|
animationEasing: 'cubic-out',
|
|
16
|
+
messages: {
|
|
17
|
+
noData: 'No data available',
|
|
18
|
+
noDataHelp: 'Please provide a value to display the gauge',
|
|
19
|
+
noDataIcon: 'fa-light fa-gauge',
|
|
20
|
+
},
|
|
16
21
|
};
|
|
17
22
|
const AX_GAUGE_CHART_CONFIG = new InjectionToken('AX_GAUGE_CHART_CONFIG', {
|
|
18
23
|
providedIn: 'root',
|
|
@@ -157,7 +162,7 @@ class AXGaugeChartComponent {
|
|
|
157
162
|
const effectiveHeight = Math.max(height, 50);
|
|
158
163
|
// For a semi-circular gauge, width should be approximately twice the height
|
|
159
164
|
const size = Math.min(effectiveWidth, effectiveHeight * 2);
|
|
160
|
-
const margin = size * 0.
|
|
165
|
+
const margin = Math.max(8, size * 0.08);
|
|
161
166
|
// Set up SVG with responsive viewBox
|
|
162
167
|
const svg = this.d3
|
|
163
168
|
.select(this.svgElement)
|
|
@@ -169,7 +174,9 @@ class AXGaugeChartComponent {
|
|
|
169
174
|
const chartGroup = svg.append('g').attr('transform', `translate(${size / 2}, ${size / 2 - margin})`);
|
|
170
175
|
// Define gauge parameters
|
|
171
176
|
const radius = size / 2 - margin;
|
|
172
|
-
const
|
|
177
|
+
const desiredGaugeWidth = typeof gaugeWidth === 'number' && !Number.isNaN(gaugeWidth) ? gaugeWidth : size * 0.12;
|
|
178
|
+
const clampedGaugeWidth = Math.max(size * 0.06, Math.min(desiredGaugeWidth, size * 0.2));
|
|
179
|
+
const innerRadius = radius - clampedGaugeWidth;
|
|
173
180
|
const outerRadius = radius;
|
|
174
181
|
// Create gradient definitions
|
|
175
182
|
this.createGradients(svg, thresholds);
|
|
@@ -180,12 +187,12 @@ class AXGaugeChartComponent {
|
|
|
180
187
|
this.drawThresholds(chartGroup, innerRadius, outerRadius, minValue, maxValue, thresholds, cornerRadius);
|
|
181
188
|
}
|
|
182
189
|
// Draw tick marks
|
|
183
|
-
this.drawTicks(chartGroup, outerRadius, minValue, maxValue);
|
|
190
|
+
this.drawTicks(chartGroup, outerRadius, minValue, maxValue, size);
|
|
184
191
|
// Draw the dial/needle with animation
|
|
185
192
|
this.drawDial(chartGroup, radius, this.value(), minValue, maxValue, animationDuration);
|
|
186
193
|
// Draw the value display (after the dial so it's on top)
|
|
187
194
|
if (showValue) {
|
|
188
|
-
this.drawValueDisplay(chartGroup, this.value(), label, radius);
|
|
195
|
+
this.drawValueDisplay(chartGroup, this.value(), label, radius, size);
|
|
189
196
|
}
|
|
190
197
|
// Hide tooltip initially
|
|
191
198
|
this._tooltipVisible.set(false);
|
|
@@ -209,11 +216,6 @@ class AXGaugeChartComponent {
|
|
|
209
216
|
const easingFunction = this.getEasingFunction(options.animationEasing);
|
|
210
217
|
const currentValue = value;
|
|
211
218
|
const svg = this.d3.select(this.svgElement);
|
|
212
|
-
// Get chart size from SVG viewBox
|
|
213
|
-
const viewBoxValues = svg.attr('viewBox')?.split(' ').map(Number) || [0, 0, 300, 150];
|
|
214
|
-
const size = viewBoxValues[2];
|
|
215
|
-
const margin = size * 0.1;
|
|
216
|
-
const radius = size / 2 - margin;
|
|
217
219
|
// Update value text
|
|
218
220
|
svg.select('.gauge-value').text(currentValue.toLocaleString());
|
|
219
221
|
// Update needle position
|
|
@@ -392,10 +394,8 @@ class AXGaugeChartComponent {
|
|
|
392
394
|
const y = event.clientY - container.top;
|
|
393
395
|
// Get container dimensions to check if we're near the edge
|
|
394
396
|
const containerWidth = container.width;
|
|
395
|
-
const containerHeight = container.height;
|
|
396
397
|
// Tooltip dimensions approximation (can't get exact dimensions without rendering)
|
|
397
398
|
const tooltipWidth = 150; // Approximate width of tooltip
|
|
398
|
-
const tooltipHeight = 80; // Approximate height of tooltip
|
|
399
399
|
// Calculate position with edge detection
|
|
400
400
|
let tooltipX = x + 8; // fix overlap with cursor
|
|
401
401
|
const tooltipY = y - 12; // fix overlap with cursor
|
|
@@ -483,10 +483,17 @@ class AXGaugeChartComponent {
|
|
|
483
483
|
/**
|
|
484
484
|
* Draws tick marks and labels around the gauge
|
|
485
485
|
*/
|
|
486
|
-
drawTicks(chartGroup, radius, minValue, maxValue) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
drawTicks(chartGroup, radius, minValue, maxValue, size) {
|
|
487
|
+
// Dynamically choose tick count based on chart size
|
|
488
|
+
let tickCount = 5;
|
|
489
|
+
if (size < 260)
|
|
490
|
+
tickCount = 3;
|
|
491
|
+
else if (size < 340)
|
|
492
|
+
tickCount = 4;
|
|
493
|
+
else if (size > 520)
|
|
494
|
+
tickCount = 7;
|
|
495
|
+
const tickLength = Math.max(6, Math.min(radius * 0.12, 14));
|
|
496
|
+
const labelOffset = Math.max(radius * 0.12, 22);
|
|
490
497
|
// Create a group for the ticks
|
|
491
498
|
const tickGroup = chartGroup.append('g').attr('class', 'ticks');
|
|
492
499
|
// Generate tick values
|
|
@@ -517,7 +524,8 @@ class AXGaugeChartComponent {
|
|
|
517
524
|
.attr('y2', y2)
|
|
518
525
|
.attr('stroke', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.5)')
|
|
519
526
|
.attr('stroke-width', 2);
|
|
520
|
-
// Add tick label
|
|
527
|
+
// Add tick label with dynamic font size
|
|
528
|
+
const tickFontPx = Math.max(9, Math.min(12, Math.floor(size / 40)));
|
|
521
529
|
tickGroup
|
|
522
530
|
.append('text')
|
|
523
531
|
.attr('x', labelX)
|
|
@@ -525,18 +533,18 @@ class AXGaugeChartComponent {
|
|
|
525
533
|
.attr('text-anchor', 'middle')
|
|
526
534
|
.attr('dominant-baseline', 'middle')
|
|
527
535
|
.attr('fill', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.7)')
|
|
528
|
-
.style('font-size',
|
|
529
|
-
.text(tick.toLocaleString());
|
|
536
|
+
.style('font-size', `${tickFontPx}px`)
|
|
537
|
+
.text(tick.toFixed(0).toLocaleString());
|
|
530
538
|
});
|
|
531
539
|
}
|
|
532
540
|
/**
|
|
533
541
|
* Draws the value and label text in the center
|
|
534
542
|
*/
|
|
535
|
-
drawValueDisplay(chartGroup, value, label, radius) {
|
|
536
|
-
//
|
|
537
|
-
const
|
|
538
|
-
const
|
|
539
|
-
const
|
|
543
|
+
drawValueDisplay(chartGroup, value, label, radius, size) {
|
|
544
|
+
// Px-based scaling for robust small/large sizes
|
|
545
|
+
const valueFontPx = Math.max(14, Math.min(32, Math.floor(size / 8)));
|
|
546
|
+
const labelFontPx = Math.max(10, Math.min(16, Math.floor(valueFontPx * 0.55)));
|
|
547
|
+
const verticalGap = Math.max(4, Math.min(10, Math.floor(size / 60)));
|
|
540
548
|
// Create group for the value display
|
|
541
549
|
const valueGroup = chartGroup.append('g').attr('class', 'gauge-value-display').attr('text-anchor', 'middle');
|
|
542
550
|
// Add value display
|
|
@@ -544,8 +552,8 @@ class AXGaugeChartComponent {
|
|
|
544
552
|
.append('text')
|
|
545
553
|
.attr('class', 'gauge-value')
|
|
546
554
|
.attr('x', 0)
|
|
547
|
-
.attr('y', radius * 0.
|
|
548
|
-
.style('font-size', `${
|
|
555
|
+
.attr('y', radius * 0.15 + valueFontPx)
|
|
556
|
+
.style('font-size', `${valueFontPx}px`)
|
|
549
557
|
.style('font-weight', '600')
|
|
550
558
|
.style('fill', 'rgb(var(--ax-comp-gauge-chart-text-color))')
|
|
551
559
|
.text(value.toLocaleString());
|
|
@@ -555,8 +563,8 @@ class AXGaugeChartComponent {
|
|
|
555
563
|
.append('text')
|
|
556
564
|
.attr('class', 'gauge-label')
|
|
557
565
|
.attr('x', 0)
|
|
558
|
-
.attr('y', radius * 0.
|
|
559
|
-
.style('font-size', `${
|
|
566
|
+
.attr('y', radius * 0.24 + valueFontPx + verticalGap)
|
|
567
|
+
.style('font-size', `${labelFontPx}px`)
|
|
560
568
|
.style('fill', 'rgb(var(--ax-comp-gauge-chart-text-color))')
|
|
561
569
|
.style('opacity', '0.8')
|
|
562
570
|
.text(label);
|
|
@@ -670,12 +678,12 @@ class AXGaugeChartComponent {
|
|
|
670
678
|
radiansToDegrees(radians) {
|
|
671
679
|
return radians * (180 / Math.PI);
|
|
672
680
|
}
|
|
673
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.
|
|
674
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.1.
|
|
681
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXGaugeChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
682
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.1.8", type: AXGaugeChartComponent, isStandalone: true, selector: "ax-gauge-chart", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "chartContainerEl", first: true, predicate: ["chartContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"ax-gauge-chart\" #chartContainer></div>\n<ax-chart-tooltip [data]=\"tooltipData()\" [position]=\"tooltipPosition()\" [visible]=\"tooltipVisible()\"></ax-chart-tooltip>\n", styles: ["ax-gauge-chart{display:block;width:100%;height:100%;min-height:200px;--ax-comp-gauge-chart-bg-color: var(--ax-sys-color-lightest-surface);--ax-comp-gauge-chart-text-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-gauge-chart-track-color: var(--ax-sys-color-dark-surface);--ax-comp-gauge-chart-needle-color: var(--ax-sys-color-primary-500)}ax-gauge-chart .ax-gauge-chart{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:visible;color:rgb(var(--ax-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color));border-radius:.5rem}ax-gauge-chart .ax-gauge-chart svg{width:100%;height:100%;max-width:100%;max-height:100%;overflow:visible}ax-gauge-chart .ax-gauge-chart svg g:has(text){font-family:inherit}ax-gauge-chart .ax-gauge-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-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color))}ax-gauge-chart .ax-gauge-chart-no-data-icon{margin-bottom:.75rem;color:rgba(var(--ax-comp-gauge-chart-text-color),.6)}ax-gauge-chart .ax-gauge-chart-no-data-text{font-weight:600;color:rgb(var(--ax-comp-gauge-chart-text-color))}\n"], dependencies: [{ kind: "component", type: AXChartTooltipComponent, selector: "ax-chart-tooltip", inputs: ["data", "position", "visible", "showPercentage", "style"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
675
683
|
}
|
|
676
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.
|
|
684
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXGaugeChartComponent, decorators: [{
|
|
677
685
|
type: Component,
|
|
678
|
-
args: [{ selector: 'ax-gauge-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"ax-gauge-chart\" #chartContainer></div>\n<ax-chart-tooltip [data]=\"tooltipData()\" [position]=\"tooltipPosition()\" [visible]=\"tooltipVisible()\"></ax-chart-tooltip>\n", styles: ["ax-gauge-chart{display:block;width:100%;height:100%;min-height:200px;--ax-comp-gauge-chart-bg-color: var(--ax-sys-color-lightest-surface);--ax-comp-gauge-chart-text-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-gauge-chart-track-color: var(--ax-sys-color-dark-surface);--ax-comp-gauge-chart-needle-color: var(--ax-sys-color-primary-500)}ax-gauge-chart .ax-gauge-chart{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:visible;color:rgb(var(--ax-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color));border-radius:.5rem}ax-gauge-chart .ax-gauge-chart svg{width:100%;height:100%;max-width:100%;max-height:100%;overflow:visible}ax-gauge-chart .ax-gauge-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-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color))}ax-gauge-chart .ax-gauge-chart-no-data-icon{margin-bottom:.75rem;color:rgba(var(--ax-comp-gauge-chart-text-color),.6)}ax-gauge-chart .ax-gauge-chart-no-data-text{font-weight:600;color:rgb(var(--ax-comp-gauge-chart-text-color))}\n"] }]
|
|
686
|
+
args: [{ selector: 'ax-gauge-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"ax-gauge-chart\" #chartContainer></div>\n<ax-chart-tooltip [data]=\"tooltipData()\" [position]=\"tooltipPosition()\" [visible]=\"tooltipVisible()\"></ax-chart-tooltip>\n", styles: ["ax-gauge-chart{display:block;width:100%;height:100%;min-height:200px;--ax-comp-gauge-chart-bg-color: var(--ax-sys-color-lightest-surface);--ax-comp-gauge-chart-text-color: var(--ax-sys-color-on-lightest-surface);--ax-comp-gauge-chart-track-color: var(--ax-sys-color-dark-surface);--ax-comp-gauge-chart-needle-color: var(--ax-sys-color-primary-500)}ax-gauge-chart .ax-gauge-chart{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:visible;color:rgb(var(--ax-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color));border-radius:.5rem}ax-gauge-chart .ax-gauge-chart svg{width:100%;height:100%;max-width:100%;max-height:100%;overflow:visible}ax-gauge-chart .ax-gauge-chart svg g:has(text){font-family:inherit}ax-gauge-chart .ax-gauge-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-comp-gauge-chart-text-color));background-color:rgb(var(--ax-comp-gauge-chart-bg-color))}ax-gauge-chart .ax-gauge-chart-no-data-icon{margin-bottom:.75rem;color:rgba(var(--ax-comp-gauge-chart-text-color),.6)}ax-gauge-chart .ax-gauge-chart-no-data-text{font-weight:600;color:rgb(var(--ax-comp-gauge-chart-text-color))}\n"] }]
|
|
679
687
|
}], ctorParameters: () => [] });
|
|
680
688
|
|
|
681
689
|
/**
|