@acorex/charts 20.1.23 → 20.1.25
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 +24 -3
- package/chart-legend/index.d.ts +1 -1
- package/chart-tooltip/index.d.ts +11 -4
- package/donut-chart/index.d.ts +1 -0
- package/fesm2022/acorex-charts-bar-chart.mjs +469 -111
- 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 +95 -86
- package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-gauge-chart.mjs +33 -30
- package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-hierarchy-chart.mjs +3 -3
- package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-line-chart.mjs +20 -18
- package/fesm2022/acorex-charts-line-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts.mjs +16 -0
- package/fesm2022/acorex-charts.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -157,7 +157,7 @@ class AXGaugeChartComponent {
|
|
|
157
157
|
const effectiveHeight = Math.max(height, 50);
|
|
158
158
|
// For a semi-circular gauge, width should be approximately twice the height
|
|
159
159
|
const size = Math.min(effectiveWidth, effectiveHeight * 2);
|
|
160
|
-
const margin = size * 0.
|
|
160
|
+
const margin = Math.max(8, size * 0.08);
|
|
161
161
|
// Set up SVG with responsive viewBox
|
|
162
162
|
const svg = this.d3
|
|
163
163
|
.select(this.svgElement)
|
|
@@ -169,7 +169,9 @@ class AXGaugeChartComponent {
|
|
|
169
169
|
const chartGroup = svg.append('g').attr('transform', `translate(${size / 2}, ${size / 2 - margin})`);
|
|
170
170
|
// Define gauge parameters
|
|
171
171
|
const radius = size / 2 - margin;
|
|
172
|
-
const
|
|
172
|
+
const desiredGaugeWidth = typeof gaugeWidth === 'number' && !Number.isNaN(gaugeWidth) ? gaugeWidth : size * 0.12;
|
|
173
|
+
const clampedGaugeWidth = Math.max(size * 0.06, Math.min(desiredGaugeWidth, size * 0.2));
|
|
174
|
+
const innerRadius = radius - clampedGaugeWidth;
|
|
173
175
|
const outerRadius = radius;
|
|
174
176
|
// Create gradient definitions
|
|
175
177
|
this.createGradients(svg, thresholds);
|
|
@@ -180,12 +182,12 @@ class AXGaugeChartComponent {
|
|
|
180
182
|
this.drawThresholds(chartGroup, innerRadius, outerRadius, minValue, maxValue, thresholds, cornerRadius);
|
|
181
183
|
}
|
|
182
184
|
// Draw tick marks
|
|
183
|
-
this.drawTicks(chartGroup, outerRadius, minValue, maxValue);
|
|
185
|
+
this.drawTicks(chartGroup, outerRadius, minValue, maxValue, size);
|
|
184
186
|
// Draw the dial/needle with animation
|
|
185
187
|
this.drawDial(chartGroup, radius, this.value(), minValue, maxValue, animationDuration);
|
|
186
188
|
// Draw the value display (after the dial so it's on top)
|
|
187
189
|
if (showValue) {
|
|
188
|
-
this.drawValueDisplay(chartGroup, this.value(), label, radius);
|
|
190
|
+
this.drawValueDisplay(chartGroup, this.value(), label, radius, size);
|
|
189
191
|
}
|
|
190
192
|
// Hide tooltip initially
|
|
191
193
|
this._tooltipVisible.set(false);
|
|
@@ -209,11 +211,6 @@ class AXGaugeChartComponent {
|
|
|
209
211
|
const easingFunction = this.getEasingFunction(options.animationEasing);
|
|
210
212
|
const currentValue = value;
|
|
211
213
|
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
214
|
// Update value text
|
|
218
215
|
svg.select('.gauge-value').text(currentValue.toLocaleString());
|
|
219
216
|
// Update needle position
|
|
@@ -392,10 +389,8 @@ class AXGaugeChartComponent {
|
|
|
392
389
|
const y = event.clientY - container.top;
|
|
393
390
|
// Get container dimensions to check if we're near the edge
|
|
394
391
|
const containerWidth = container.width;
|
|
395
|
-
const containerHeight = container.height;
|
|
396
392
|
// Tooltip dimensions approximation (can't get exact dimensions without rendering)
|
|
397
393
|
const tooltipWidth = 150; // Approximate width of tooltip
|
|
398
|
-
const tooltipHeight = 80; // Approximate height of tooltip
|
|
399
394
|
// Calculate position with edge detection
|
|
400
395
|
let tooltipX = x + 8; // fix overlap with cursor
|
|
401
396
|
const tooltipY = y - 12; // fix overlap with cursor
|
|
@@ -483,10 +478,17 @@ class AXGaugeChartComponent {
|
|
|
483
478
|
/**
|
|
484
479
|
* Draws tick marks and labels around the gauge
|
|
485
480
|
*/
|
|
486
|
-
drawTicks(chartGroup, radius, minValue, maxValue) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
481
|
+
drawTicks(chartGroup, radius, minValue, maxValue, size) {
|
|
482
|
+
// Dynamically choose tick count based on chart size
|
|
483
|
+
let tickCount = 5;
|
|
484
|
+
if (size < 260)
|
|
485
|
+
tickCount = 3;
|
|
486
|
+
else if (size < 340)
|
|
487
|
+
tickCount = 4;
|
|
488
|
+
else if (size > 520)
|
|
489
|
+
tickCount = 7;
|
|
490
|
+
const tickLength = Math.max(6, Math.min(radius * 0.12, 14));
|
|
491
|
+
const labelOffset = Math.max(radius * 0.12, 22);
|
|
490
492
|
// Create a group for the ticks
|
|
491
493
|
const tickGroup = chartGroup.append('g').attr('class', 'ticks');
|
|
492
494
|
// Generate tick values
|
|
@@ -517,7 +519,8 @@ class AXGaugeChartComponent {
|
|
|
517
519
|
.attr('y2', y2)
|
|
518
520
|
.attr('stroke', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.5)')
|
|
519
521
|
.attr('stroke-width', 2);
|
|
520
|
-
// Add tick label
|
|
522
|
+
// Add tick label with dynamic font size
|
|
523
|
+
const tickFontPx = Math.max(9, Math.min(12, Math.floor(size / 40)));
|
|
521
524
|
tickGroup
|
|
522
525
|
.append('text')
|
|
523
526
|
.attr('x', labelX)
|
|
@@ -525,18 +528,18 @@ class AXGaugeChartComponent {
|
|
|
525
528
|
.attr('text-anchor', 'middle')
|
|
526
529
|
.attr('dominant-baseline', 'middle')
|
|
527
530
|
.attr('fill', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.7)')
|
|
528
|
-
.style('font-size',
|
|
529
|
-
.text(tick.toLocaleString());
|
|
531
|
+
.style('font-size', `${tickFontPx}px`)
|
|
532
|
+
.text(tick.toFixed(0).toLocaleString());
|
|
530
533
|
});
|
|
531
534
|
}
|
|
532
535
|
/**
|
|
533
536
|
* Draws the value and label text in the center
|
|
534
537
|
*/
|
|
535
|
-
drawValueDisplay(chartGroup, value, label, radius) {
|
|
536
|
-
//
|
|
537
|
-
const
|
|
538
|
-
const
|
|
539
|
-
const
|
|
538
|
+
drawValueDisplay(chartGroup, value, label, radius, size) {
|
|
539
|
+
// Px-based scaling for robust small/large sizes
|
|
540
|
+
const valueFontPx = Math.max(14, Math.min(32, Math.floor(size / 8)));
|
|
541
|
+
const labelFontPx = Math.max(10, Math.min(16, Math.floor(valueFontPx * 0.55)));
|
|
542
|
+
const verticalGap = Math.max(4, Math.min(10, Math.floor(size / 60)));
|
|
540
543
|
// Create group for the value display
|
|
541
544
|
const valueGroup = chartGroup.append('g').attr('class', 'gauge-value-display').attr('text-anchor', 'middle');
|
|
542
545
|
// Add value display
|
|
@@ -544,8 +547,8 @@ class AXGaugeChartComponent {
|
|
|
544
547
|
.append('text')
|
|
545
548
|
.attr('class', 'gauge-value')
|
|
546
549
|
.attr('x', 0)
|
|
547
|
-
.attr('y', radius * 0.
|
|
548
|
-
.style('font-size', `${
|
|
550
|
+
.attr('y', radius * 0.15 + valueFontPx)
|
|
551
|
+
.style('font-size', `${valueFontPx}px`)
|
|
549
552
|
.style('font-weight', '600')
|
|
550
553
|
.style('fill', 'rgb(var(--ax-comp-gauge-chart-text-color))')
|
|
551
554
|
.text(value.toLocaleString());
|
|
@@ -555,8 +558,8 @@ class AXGaugeChartComponent {
|
|
|
555
558
|
.append('text')
|
|
556
559
|
.attr('class', 'gauge-label')
|
|
557
560
|
.attr('x', 0)
|
|
558
|
-
.attr('y', radius * 0.
|
|
559
|
-
.style('font-size', `${
|
|
561
|
+
.attr('y', radius * 0.24 + valueFontPx + verticalGap)
|
|
562
|
+
.style('font-size', `${labelFontPx}px`)
|
|
560
563
|
.style('fill', 'rgb(var(--ax-comp-gauge-chart-text-color))')
|
|
561
564
|
.style('opacity', '0.8')
|
|
562
565
|
.text(label);
|
|
@@ -670,10 +673,10 @@ class AXGaugeChartComponent {
|
|
|
670
673
|
radiansToDegrees(radians) {
|
|
671
674
|
return radians * (180 / Math.PI);
|
|
672
675
|
}
|
|
673
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.
|
|
674
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.1.
|
|
676
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXGaugeChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
677
|
+
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-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
678
|
}
|
|
676
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.
|
|
679
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: AXGaugeChartComponent, decorators: [{
|
|
677
680
|
type: Component,
|
|
678
681
|
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"] }]
|
|
679
682
|
}], ctorParameters: () => [] });
|