@acorex/charts 21.0.0-next.2 → 21.0.0-next.21
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 +67 -7
- package/donut-chart/index.d.ts +46 -8
- package/fesm2022/acorex-charts-bar-chart.mjs +342 -124
- package/fesm2022/acorex-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-chart-legend.mjs +4 -4
- package/fesm2022/acorex-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/acorex-charts-chart-tooltip.mjs +4 -4
- package/fesm2022/acorex-charts-chart-tooltip.mjs.map +1 -1
- package/fesm2022/acorex-charts-donut-chart.mjs +298 -200
- package/fesm2022/acorex-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-gauge-chart.mjs +93 -68
- package/fesm2022/acorex-charts-gauge-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-hierarchy-chart.mjs +22 -16
- package/fesm2022/acorex-charts-hierarchy-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts-line-chart.mjs +295 -153
- package/fesm2022/acorex-charts-line-chart.mjs.map +1 -1
- package/fesm2022/acorex-charts.mjs +93 -7
- package/fesm2022/acorex-charts.mjs.map +1 -1
- package/gauge-chart/index.d.ts +10 -7
- package/hierarchy-chart/index.d.ts +4 -5
- package/index.d.ts +43 -4
- package/line-chart/index.d.ts +70 -7
- package/package.json +1 -3
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { getEasingFunction, computeTooltipPosition } from '@acorex/charts';
|
|
1
|
+
import { AXChartComponent, getEasingFunction, computeTooltipPosition, formatLargeNumber } from '@acorex/charts';
|
|
2
2
|
import { AXChartTooltipComponent } from '@acorex/charts/chart-tooltip';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken,
|
|
5
|
-
import { AX_GLOBAL_CONFIG } from '@acorex/core/config';
|
|
6
|
-
import { set } from 'lodash-es';
|
|
4
|
+
import { InjectionToken, input, viewChild, signal, inject, computed, afterNextRender, effect, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
|
|
7
5
|
|
|
8
6
|
const AXGaugeChartDefaultConfig = {
|
|
9
7
|
minValue: 0,
|
|
@@ -22,11 +20,7 @@ const AXGaugeChartDefaultConfig = {
|
|
|
22
20
|
};
|
|
23
21
|
const AX_GAUGE_CHART_CONFIG = new InjectionToken('AX_GAUGE_CHART_CONFIG', {
|
|
24
22
|
providedIn: 'root',
|
|
25
|
-
factory: () =>
|
|
26
|
-
const global = inject(AX_GLOBAL_CONFIG);
|
|
27
|
-
set(global, 'chart.gaugeChart', AXGaugeChartDefaultConfig);
|
|
28
|
-
return AXGaugeChartDefaultConfig;
|
|
29
|
-
},
|
|
23
|
+
factory: () => AXGaugeChartDefaultConfig,
|
|
30
24
|
});
|
|
31
25
|
function gaugeChartConfig(config = {}) {
|
|
32
26
|
const result = {
|
|
@@ -40,9 +34,7 @@ function gaugeChartConfig(config = {}) {
|
|
|
40
34
|
* Gauge Chart Component
|
|
41
35
|
* Renders a semi-circular gauge chart with animated needle and thresholds
|
|
42
36
|
*/
|
|
43
|
-
class AXGaugeChartComponent {
|
|
44
|
-
// Inject ChangeDetectorRef
|
|
45
|
-
cdr = inject(ChangeDetectorRef);
|
|
37
|
+
class AXGaugeChartComponent extends AXChartComponent {
|
|
46
38
|
// Inputs
|
|
47
39
|
/** Chart value input */
|
|
48
40
|
value = input(0, ...(ngDevMode ? [{ debugName: "value" }] : []));
|
|
@@ -60,6 +52,8 @@ class AXGaugeChartComponent {
|
|
|
60
52
|
_prevValue = signal(null, ...(ngDevMode ? [{ debugName: "_prevValue" }] : []));
|
|
61
53
|
// Track previous options to detect changes
|
|
62
54
|
_prevOptionsString = '';
|
|
55
|
+
// Cache for container dimensions to avoid repeated DOM reads
|
|
56
|
+
_lastContainerRect = null;
|
|
63
57
|
// Tooltip signals
|
|
64
58
|
_tooltipVisible = signal(false, ...(ngDevMode ? [{ debugName: "_tooltipVisible" }] : []));
|
|
65
59
|
_tooltipPosition = signal({ x: 0, y: 0 }, ...(ngDevMode ? [{ debugName: "_tooltipPosition" }] : []));
|
|
@@ -80,9 +74,13 @@ class AXGaugeChartComponent {
|
|
|
80
74
|
...this.options(),
|
|
81
75
|
};
|
|
82
76
|
}, ...(ngDevMode ? [{ debugName: "effectiveOptions" }] : []));
|
|
83
|
-
//
|
|
77
|
+
// Constants
|
|
84
78
|
TOOLTIP_GAP = 10;
|
|
79
|
+
HALF_CIRCLE_RADIANS = Math.PI;
|
|
80
|
+
QUARTER_CIRCLE_RADIANS = Math.PI / 2;
|
|
81
|
+
DEGREES_PER_RADIAN = 180 / Math.PI;
|
|
85
82
|
constructor() {
|
|
83
|
+
super();
|
|
86
84
|
// Dynamically load D3 and initialize the chart when the component is ready
|
|
87
85
|
afterNextRender(() => {
|
|
88
86
|
this._initialized.set(true);
|
|
@@ -117,6 +115,8 @@ class AXGaugeChartComponent {
|
|
|
117
115
|
* Loads D3.js dynamically
|
|
118
116
|
*/
|
|
119
117
|
async loadD3() {
|
|
118
|
+
if (this.d3)
|
|
119
|
+
return; // Already loaded
|
|
120
120
|
try {
|
|
121
121
|
this.d3 = await import('d3');
|
|
122
122
|
// If container is ready, create chart
|
|
@@ -144,37 +144,44 @@ class AXGaugeChartComponent {
|
|
|
144
144
|
const options = this.effectiveOptions();
|
|
145
145
|
// Store options string for comparison
|
|
146
146
|
this._prevOptionsString = JSON.stringify(options);
|
|
147
|
-
|
|
148
|
-
const showValue = options.showValue;
|
|
149
|
-
const minValue = options.minValue;
|
|
150
|
-
const maxValue = options.maxValue;
|
|
147
|
+
const { minValue, maxValue, showValue, label = '', gaugeWidth, cornerRadius, animationDuration } = options;
|
|
151
148
|
const thresholds = options.thresholds ?? [];
|
|
152
|
-
const label = options.label ?? '';
|
|
153
|
-
const gaugeWidth = options.gaugeWidth;
|
|
154
|
-
const cornerRadius = options.cornerRadius;
|
|
155
|
-
const animationDuration = options.animationDuration;
|
|
156
149
|
// Calculate responsive dimensions
|
|
157
150
|
const containerElement = this.chartContainerEl().nativeElement;
|
|
158
151
|
const containerWidth = containerElement.clientWidth;
|
|
159
152
|
const containerHeight = containerElement.clientHeight;
|
|
153
|
+
// Cache container dimensions
|
|
154
|
+
this._lastContainerRect = { width: containerWidth, height: containerHeight };
|
|
160
155
|
// Determine chart dimensions - use options if provided, otherwise use container dimensions
|
|
161
|
-
const width = options.width
|
|
162
|
-
const height = options.height
|
|
156
|
+
const width = options.width ?? containerWidth;
|
|
157
|
+
const height = options.height ?? containerHeight;
|
|
163
158
|
// Ensure minimum dimensions
|
|
164
159
|
const effectiveWidth = Math.max(width, 100);
|
|
165
160
|
const effectiveHeight = Math.max(height, 50);
|
|
166
161
|
// For a semi-circular gauge, width should be approximately twice the height
|
|
167
162
|
const size = Math.min(effectiveWidth, effectiveHeight * 2);
|
|
168
|
-
|
|
169
|
-
|
|
163
|
+
// Calculate margin as percentage of size (5-8% with reasonable bounds)
|
|
164
|
+
const marginRatio = 0.08;
|
|
165
|
+
const margin = Math.max(5, Math.min(size * marginRatio, 30));
|
|
166
|
+
// Calculate space needed for ticks and labels (increased for larger font sizes)
|
|
167
|
+
const tickLabelSpace = Math.max(12, Math.min(size * 0.12, 40));
|
|
168
|
+
const totalVerticalSpace = size / 2 + tickLabelSpace;
|
|
169
|
+
// Calculate horizontal padding for tick labels (they extend beyond gauge edges)
|
|
170
|
+
// Estimate based on font size - tick labels are roughly 2-3 characters wide
|
|
171
|
+
const estimatedTickFontSize = Math.max(14, Math.min(18, Math.floor(size / 35)));
|
|
172
|
+
const horizontalPadding = Math.max(20, estimatedTickFontSize * 1.5);
|
|
173
|
+
const totalWidth = size + horizontalPadding * 2;
|
|
174
|
+
// Set up SVG with responsive viewBox that accounts for overflow
|
|
170
175
|
const svg = this.d3
|
|
171
176
|
.select(this.svgElement)
|
|
172
177
|
.attr('width', '100%')
|
|
173
178
|
.attr('height', '100%')
|
|
174
|
-
.attr('viewBox', `0 0 ${
|
|
179
|
+
.attr('viewBox', `0 0 ${totalWidth} ${totalVerticalSpace}`)
|
|
175
180
|
.attr('preserveAspectRatio', 'xMidYMid meet');
|
|
176
|
-
// Create a group for the chart
|
|
177
|
-
const chartGroup = svg
|
|
181
|
+
// Create a group for the chart centered horizontally with padding, positioned to show only the top half
|
|
182
|
+
const chartGroup = svg
|
|
183
|
+
.append('g')
|
|
184
|
+
.attr('transform', `translate(${size / 2 + horizontalPadding}, ${size / 2 - margin})`);
|
|
178
185
|
// Define gauge parameters
|
|
179
186
|
const radius = size / 2 - margin;
|
|
180
187
|
const desiredGaugeWidth = typeof gaugeWidth === 'number' && !Number.isNaN(gaugeWidth) ? gaugeWidth : size * 0.12;
|
|
@@ -223,7 +230,7 @@ class AXGaugeChartComponent {
|
|
|
223
230
|
svg.select('.gauge-value').text(currentValue.toLocaleString());
|
|
224
231
|
// Update needle position
|
|
225
232
|
const angle = this.scaleValueToAngle(currentValue, minValue, maxValue);
|
|
226
|
-
const angleInDegrees = this.radiansToDegrees(angle -
|
|
233
|
+
const angleInDegrees = this.radiansToDegrees(angle - this.QUARTER_CIRCLE_RADIANS);
|
|
227
234
|
svg
|
|
228
235
|
.select('.gauge-needle')
|
|
229
236
|
.attr('fill', 'rgb(var(--ax-comp-gauge-chart-needle-color))')
|
|
@@ -241,8 +248,8 @@ class AXGaugeChartComponent {
|
|
|
241
248
|
.arc()
|
|
242
249
|
.innerRadius(innerRadius)
|
|
243
250
|
.outerRadius(outerRadius)
|
|
244
|
-
.startAngle(-
|
|
245
|
-
.endAngle(
|
|
251
|
+
.startAngle(-this.QUARTER_CIRCLE_RADIANS) // Start from bottom (-90 degrees)
|
|
252
|
+
.endAngle(this.QUARTER_CIRCLE_RADIANS) // End at top (90 degrees)
|
|
246
253
|
.cornerRadius(cornerRadius);
|
|
247
254
|
// Draw background arc
|
|
248
255
|
const backgroundPath = chartGroup
|
|
@@ -280,8 +287,8 @@ class AXGaugeChartComponent {
|
|
|
280
287
|
.innerRadius(innerRadius)
|
|
281
288
|
.outerRadius(outerRadius * 0.98)
|
|
282
289
|
.cornerRadius(cornerRadius);
|
|
283
|
-
// Sort thresholds by value in ascending order
|
|
284
|
-
const sortedThresholds = [...thresholds].sort((a, b) => a.value - b.value);
|
|
290
|
+
// Sort thresholds by value in ascending order (only if needed)
|
|
291
|
+
const sortedThresholds = thresholds.length > 1 ? [...thresholds].sort((a, b) => a.value - b.value) : thresholds;
|
|
285
292
|
// Calculate all angles first using the color angle calculation
|
|
286
293
|
const angles = sortedThresholds.map((t) => this.scaleValueToColorAngle(t.value, minValue, maxValue));
|
|
287
294
|
// Start from the minimum value angle
|
|
@@ -325,14 +332,14 @@ class AXGaugeChartComponent {
|
|
|
325
332
|
previousEndAngle = endAngle;
|
|
326
333
|
});
|
|
327
334
|
// Draw the last segment if the last threshold is less than the max value
|
|
328
|
-
if (previousEndAngle <
|
|
335
|
+
if (previousEndAngle < this.QUARTER_CIRCLE_RADIANS) {
|
|
329
336
|
const lastArc = chartGroup
|
|
330
337
|
.append('path')
|
|
331
338
|
.attr('d', arc({
|
|
332
339
|
innerRadius,
|
|
333
340
|
outerRadius,
|
|
334
341
|
startAngle: previousEndAngle,
|
|
335
|
-
endAngle:
|
|
342
|
+
endAngle: this.QUARTER_CIRCLE_RADIANS,
|
|
336
343
|
}))
|
|
337
344
|
.attr('fill', 'url(#gauge-bg-gradient)')
|
|
338
345
|
.attr('class', 'gauge-arc threshold-arc')
|
|
@@ -370,7 +377,6 @@ class AXGaugeChartComponent {
|
|
|
370
377
|
// Show tooltip
|
|
371
378
|
this._tooltipVisible.set(true);
|
|
372
379
|
this.updateTooltipPosition(event);
|
|
373
|
-
this.cdr.detectChanges();
|
|
374
380
|
}
|
|
375
381
|
/**
|
|
376
382
|
* Shows tooltip for the entire range when no thresholds are defined
|
|
@@ -386,10 +392,10 @@ class AXGaugeChartComponent {
|
|
|
386
392
|
color: 'rgb(var(--ax-comp-gauge-chart-track-color))',
|
|
387
393
|
});
|
|
388
394
|
this._tooltipVisible.set(true);
|
|
389
|
-
this.cdr.detectChanges();
|
|
390
395
|
}
|
|
391
396
|
/**
|
|
392
397
|
* Updates the tooltip position based on the mouse event
|
|
398
|
+
* For gauge charts, we need simpler coordinate handling since D3 events are already in container coordinates
|
|
393
399
|
*/
|
|
394
400
|
updateTooltipPosition(event) {
|
|
395
401
|
const containerEl = this.chartContainerEl()?.nativeElement;
|
|
@@ -397,17 +403,18 @@ class AXGaugeChartComponent {
|
|
|
397
403
|
return;
|
|
398
404
|
const rect = containerEl.getBoundingClientRect();
|
|
399
405
|
const tooltipEl = containerEl.querySelector('.chart-tooltip');
|
|
400
|
-
const tooltipRect = tooltipEl
|
|
401
|
-
|
|
406
|
+
const tooltipRect = tooltipEl?.getBoundingClientRect() ?? null;
|
|
407
|
+
// Position the tooltip slightly above and to the right of the cursor for better visibility
|
|
408
|
+
const tooltipX = event.clientX + 10;
|
|
409
|
+
const tooltipY = event.clientY - 10;
|
|
410
|
+
const pos = computeTooltipPosition(rect, tooltipRect, tooltipX, tooltipY, this.TOOLTIP_GAP);
|
|
402
411
|
this._tooltipPosition.set(pos);
|
|
403
|
-
this.cdr.detectChanges();
|
|
404
412
|
}
|
|
405
413
|
/**
|
|
406
414
|
* Hides the tooltip
|
|
407
415
|
*/
|
|
408
416
|
hideTooltip() {
|
|
409
417
|
this._tooltipVisible.set(false);
|
|
410
|
-
this.cdr.detectChanges();
|
|
411
418
|
}
|
|
412
419
|
/**
|
|
413
420
|
* Cleans up chart resources
|
|
@@ -418,6 +425,7 @@ class AXGaugeChartComponent {
|
|
|
418
425
|
this.svgElement = null;
|
|
419
426
|
}
|
|
420
427
|
this._tooltipVisible.set(false);
|
|
428
|
+
this._lastContainerRect = null;
|
|
421
429
|
}
|
|
422
430
|
/**
|
|
423
431
|
* Creates gradient definitions for thresholds
|
|
@@ -469,16 +477,20 @@ class AXGaugeChartComponent {
|
|
|
469
477
|
* Draws tick marks and labels around the gauge
|
|
470
478
|
*/
|
|
471
479
|
drawTicks(chartGroup, radius, minValue, maxValue, size) {
|
|
472
|
-
// Dynamically choose tick count based on chart size
|
|
480
|
+
// Dynamically choose tick count based on chart size (reduced for better spacing)
|
|
473
481
|
let tickCount = 5;
|
|
474
|
-
if (size <
|
|
475
|
-
tickCount = 3;
|
|
476
|
-
else if (size <
|
|
482
|
+
if (size < 200)
|
|
483
|
+
tickCount = 3; // Very small: only show min, mid, max
|
|
484
|
+
else if (size < 300)
|
|
477
485
|
tickCount = 4;
|
|
486
|
+
else if (size < 400)
|
|
487
|
+
tickCount = 5;
|
|
478
488
|
else if (size > 520)
|
|
479
489
|
tickCount = 7;
|
|
480
|
-
|
|
481
|
-
const
|
|
490
|
+
// Scale tick length and label offset proportionally to size
|
|
491
|
+
const tickLength = Math.max(4, Math.min(radius * 0.12, 14));
|
|
492
|
+
// Increased label offset to prevent overlap with tick lines and wide labels (like 100M)
|
|
493
|
+
const labelOffset = Math.max(22, Math.min(radius * 0.28, 45));
|
|
482
494
|
// Create a group for the ticks
|
|
483
495
|
const tickGroup = chartGroup.append('g').attr('class', 'ticks');
|
|
484
496
|
// Generate tick values
|
|
@@ -491,7 +503,7 @@ class AXGaugeChartComponent {
|
|
|
491
503
|
tickValues.forEach((tick) => {
|
|
492
504
|
// Calculate angle for this tick
|
|
493
505
|
const angle = this.scaleValueToAngle(tick, minValue, maxValue);
|
|
494
|
-
const radians = angle -
|
|
506
|
+
const radians = angle - this.QUARTER_CIRCLE_RADIANS; // Adjust for starting at bottom (-90 degrees)
|
|
495
507
|
// Calculate positions
|
|
496
508
|
const x1 = Math.cos(radians) * (radius + 5);
|
|
497
509
|
const y1 = Math.sin(radians) * (radius + 5);
|
|
@@ -509,8 +521,23 @@ class AXGaugeChartComponent {
|
|
|
509
521
|
.attr('y2', y2)
|
|
510
522
|
.attr('stroke', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.5)')
|
|
511
523
|
.attr('stroke-width', 2);
|
|
512
|
-
// Add tick label with dynamic font size
|
|
513
|
-
const tickFontPx = Math.max(
|
|
524
|
+
// Add tick label with dynamic font size (minimum 14px)
|
|
525
|
+
const tickFontPx = Math.max(14, Math.min(18, Math.floor(size / 35)));
|
|
526
|
+
// Smart formatting: preserve decimals for small ranges, round for large values
|
|
527
|
+
const valueRange = maxValue - minValue;
|
|
528
|
+
let formattedValue;
|
|
529
|
+
if (valueRange <= 10) {
|
|
530
|
+
// Small range: show up to 2 decimal places, remove trailing zeros
|
|
531
|
+
formattedValue = tick.toFixed(2).replace(/\.?0+$/, '');
|
|
532
|
+
}
|
|
533
|
+
else if (valueRange < 1000) {
|
|
534
|
+
// Medium range: show 1 decimal if needed
|
|
535
|
+
formattedValue = tick % 1 === 0 ? tick.toString() : tick.toFixed(1);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
// Large range: use abbreviated format (K, M, B)
|
|
539
|
+
formattedValue = formatLargeNumber(Math.round(tick));
|
|
540
|
+
}
|
|
514
541
|
tickGroup
|
|
515
542
|
.append('text')
|
|
516
543
|
.attr('x', labelX)
|
|
@@ -519,17 +546,18 @@ class AXGaugeChartComponent {
|
|
|
519
546
|
.attr('dominant-baseline', 'middle')
|
|
520
547
|
.attr('fill', 'rgba(var(--ax-comp-gauge-chart-text-color), 0.7)')
|
|
521
548
|
.style('font-size', `${tickFontPx}px`)
|
|
522
|
-
.text(
|
|
549
|
+
.text(formattedValue);
|
|
523
550
|
});
|
|
524
551
|
}
|
|
525
552
|
/**
|
|
526
553
|
* Draws the value and label text in the center
|
|
527
554
|
*/
|
|
528
555
|
drawValueDisplay(chartGroup, value, label, radius, size) {
|
|
529
|
-
// Px-based scaling for robust small/large sizes
|
|
530
|
-
const valueFontPx = Math.max(
|
|
556
|
+
// Px-based scaling for robust small/large sizes with better small-size handling
|
|
557
|
+
const valueFontPx = Math.max(18, Math.min(32, Math.floor(size / 8)));
|
|
531
558
|
const labelFontPx = Math.max(10, Math.min(16, Math.floor(valueFontPx * 0.55)));
|
|
532
|
-
|
|
559
|
+
// More vertical gap for small sizes: use larger base value
|
|
560
|
+
const verticalGap = Math.max(6, Math.min(12, Math.floor(size / 40)));
|
|
533
561
|
// Create group for the value display
|
|
534
562
|
const valueGroup = chartGroup.append('g').attr('class', 'gauge-value-display').attr('text-anchor', 'middle');
|
|
535
563
|
// Add value display
|
|
@@ -563,7 +591,7 @@ class AXGaugeChartComponent {
|
|
|
563
591
|
const clampedValue = Math.max(minValue, Math.min(maxValue, value));
|
|
564
592
|
// Calculate angle for needle based on value
|
|
565
593
|
const angle = this.scaleValueToAngle(clampedValue, minValue, maxValue);
|
|
566
|
-
const angleInDegrees = this.radiansToDegrees(angle -
|
|
594
|
+
const angleInDegrees = this.radiansToDegrees(angle - this.QUARTER_CIRCLE_RADIANS);
|
|
567
595
|
// Create a group for the needle
|
|
568
596
|
const dialGroup = chartGroup.append('g').attr('class', 'dial');
|
|
569
597
|
// Draw the needle with initial position at minimum value
|
|
@@ -572,7 +600,7 @@ class AXGaugeChartComponent {
|
|
|
572
600
|
.attr('d', this.createNeedlePath(radius))
|
|
573
601
|
.attr('class', 'gauge-needle')
|
|
574
602
|
.attr('fill', 'rgb(var(--ax-comp-gauge-chart-needle-color))')
|
|
575
|
-
.attr('transform', `rotate(${this.radiansToDegrees(-
|
|
603
|
+
.attr('transform', `rotate(${this.radiansToDegrees(-this.HALF_CIRCLE_RADIANS)})`); // Start at -180 degrees (left)
|
|
576
604
|
// Add a center circle
|
|
577
605
|
dialGroup
|
|
578
606
|
.append('circle')
|
|
@@ -612,38 +640,35 @@ class AXGaugeChartComponent {
|
|
|
612
640
|
*/
|
|
613
641
|
scaleValueToAngle(value, min, max) {
|
|
614
642
|
const valueRange = max - min;
|
|
615
|
-
|
|
616
|
-
return ((value - min) / valueRange) * angleRange - Math.PI / 2;
|
|
643
|
+
return ((value - min) / valueRange) * this.HALF_CIRCLE_RADIANS - this.QUARTER_CIRCLE_RADIANS;
|
|
617
644
|
}
|
|
618
645
|
/**
|
|
619
646
|
* Scales a value to an angle for color arcs (in radians)
|
|
620
647
|
*/
|
|
621
648
|
scaleValueToColorAngle(value, min, max) {
|
|
622
649
|
const valueRange = max - min;
|
|
623
|
-
|
|
624
|
-
return ((value - min) / valueRange) * angleRange - Math.PI / 2;
|
|
650
|
+
return ((value - min) / valueRange) * this.HALF_CIRCLE_RADIANS - this.QUARTER_CIRCLE_RADIANS;
|
|
625
651
|
}
|
|
626
652
|
/**
|
|
627
653
|
* Converts an angle back to a value
|
|
628
654
|
*/
|
|
629
655
|
angleToValue(angle, min, max) {
|
|
630
656
|
const valueRange = max - min;
|
|
631
|
-
|
|
632
|
-
return min + ((angle + Math.PI / 2) / angleRange) * valueRange;
|
|
657
|
+
return min + ((angle + this.QUARTER_CIRCLE_RADIANS) / this.HALF_CIRCLE_RADIANS) * valueRange;
|
|
633
658
|
}
|
|
634
659
|
/**
|
|
635
660
|
* Converts radians to degrees
|
|
636
661
|
*/
|
|
637
662
|
radiansToDegrees(radians) {
|
|
638
|
-
return radians *
|
|
663
|
+
return radians * this.DEGREES_PER_RADIAN;
|
|
639
664
|
}
|
|
640
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
641
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.
|
|
665
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: AXGaugeChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
666
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.9", 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 }], usesInheritance: true, ngImport: i0, template: "<div class=\"ax-gauge-chart\" role=\"img\" #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: 0, 0, 0, 0;--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;color:rgb(var(--ax-comp-gauge-chart-text-color));background-color:rgba(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 });
|
|
642
667
|
}
|
|
643
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: AXGaugeChartComponent, decorators: [{
|
|
644
669
|
type: Component,
|
|
645
|
-
args: [{ selector: 'ax-gauge-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"ax-gauge-chart\" role=\"img\" #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: 0, 0, 0, 0;--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;
|
|
646
|
-
}], ctorParameters: () => [] });
|
|
670
|
+
args: [{ selector: 'ax-gauge-chart', encapsulation: ViewEncapsulation.None, imports: [AXChartTooltipComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"ax-gauge-chart\" role=\"img\" #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: 0, 0, 0, 0;--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;color:rgb(var(--ax-comp-gauge-chart-text-color));background-color:rgba(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"] }]
|
|
671
|
+
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], chartContainerEl: [{ type: i0.ViewChild, args: ['chartContainer', { isSignal: true }] }] } });
|
|
647
672
|
|
|
648
673
|
/**
|
|
649
674
|
* Generated bundle index. Do not edit.
|