@ojiepermana/angular-chart 22.0.44 → 22.0.46
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/fesm2022/ojiepermana-angular-chart-area.mjs +20 -11
- package/fesm2022/ojiepermana-angular-chart-bar.mjs +25 -14
- package/fesm2022/ojiepermana-angular-chart-core.mjs +3 -5
- package/fesm2022/ojiepermana-angular-chart-line.mjs +20 -11
- package/fesm2022/ojiepermana-angular-chart-pie.mjs +22 -11
- package/fesm2022/ojiepermana-angular-chart-primitives.mjs +111 -58
- package/fesm2022/ojiepermana-angular-chart-radar.mjs +56 -21
- package/fesm2022/ojiepermana-angular-chart-radial.mjs +22 -11
- package/fesm2022/ojiepermana-angular-chart-scatter.mjs +12 -7
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, output, computed, effect,
|
|
2
|
+
import { inject, input, output, computed, effect, Component } from '@angular/core';
|
|
3
3
|
import { ChartContext, CartesianContext, CategoricalViewportContext, sliceByIndexRange, computeAreaLayout, provideCartesianFromLineLayout, elementClientCenter } from '@ojiepermana/angular-chart/core';
|
|
4
4
|
import { ChartPointerTracker } from '@ojiepermana/angular-chart/primitives';
|
|
5
5
|
|
|
@@ -125,7 +125,8 @@ class AreaChart {
|
|
|
125
125
|
[attr.viewBox]="viewBox()"
|
|
126
126
|
preserveAspectRatio="none"
|
|
127
127
|
role="img"
|
|
128
|
-
[attr.aria-label]="ariaSummary()"
|
|
128
|
+
[attr.aria-label]="ariaSummary()"
|
|
129
|
+
>
|
|
129
130
|
@if (gradient()) {
|
|
130
131
|
<svg:defs>
|
|
131
132
|
@for (s of series(); track s.seriesKey) {
|
|
@@ -144,7 +145,8 @@ class AreaChart {
|
|
|
144
145
|
class="chart-area"
|
|
145
146
|
[attr.d]="s.areaPath"
|
|
146
147
|
[attr.fill]="areaFill(s.seriesKey, s.color)"
|
|
147
|
-
stroke="none"
|
|
148
|
+
stroke="none"
|
|
149
|
+
/>
|
|
148
150
|
<svg:path
|
|
149
151
|
class="chart-area-stroke"
|
|
150
152
|
[attr.d]="s.linePath"
|
|
@@ -152,7 +154,8 @@ class AreaChart {
|
|
|
152
154
|
[attr.stroke-width]="strokeWidth()"
|
|
153
155
|
fill="none"
|
|
154
156
|
stroke-linecap="round"
|
|
155
|
-
stroke-linejoin="round"
|
|
157
|
+
stroke-linejoin="round"
|
|
158
|
+
/>
|
|
156
159
|
@if (showDots()) {
|
|
157
160
|
@for (p of s.points; track p.datumIndex) {
|
|
158
161
|
<svg:circle
|
|
@@ -162,12 +165,14 @@ class AreaChart {
|
|
|
162
165
|
[attr.r]="dotRadius()"
|
|
163
166
|
[attr.fill]="s.color"
|
|
164
167
|
[attr.aria-label]="pointAriaLabel(p)"
|
|
168
|
+
role="img"
|
|
165
169
|
tabindex="0"
|
|
166
170
|
(focus)="setActivePoint($event, p)"
|
|
167
171
|
(blur)="clearActivePoint()"
|
|
168
172
|
(click)="emitClick(p)"
|
|
169
173
|
(keydown.enter)="emitClick(p)"
|
|
170
|
-
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
174
|
+
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
175
|
+
/>
|
|
171
176
|
}
|
|
172
177
|
}
|
|
173
178
|
}
|
|
@@ -181,13 +186,12 @@ class AreaChart {
|
|
|
181
186
|
<ng-content select="ChartTooltip" />
|
|
182
187
|
<ng-content select="ChartLegend" />
|
|
183
188
|
<ng-content select="ChartZoomControls" />
|
|
184
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }]
|
|
189
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }] });
|
|
185
190
|
}
|
|
186
191
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: AreaChart, decorators: [{
|
|
187
192
|
type: Component,
|
|
188
193
|
args: [{
|
|
189
194
|
selector: 'ChartArea',
|
|
190
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
191
195
|
providers: [CartesianContext, CategoricalViewportContext],
|
|
192
196
|
imports: [ChartPointerTracker],
|
|
193
197
|
host: { class: 'relative block h-full w-full', '[attr.data-style]': 'styles()' },
|
|
@@ -198,7 +202,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
198
202
|
[attr.viewBox]="viewBox()"
|
|
199
203
|
preserveAspectRatio="none"
|
|
200
204
|
role="img"
|
|
201
|
-
[attr.aria-label]="ariaSummary()"
|
|
205
|
+
[attr.aria-label]="ariaSummary()"
|
|
206
|
+
>
|
|
202
207
|
@if (gradient()) {
|
|
203
208
|
<svg:defs>
|
|
204
209
|
@for (s of series(); track s.seriesKey) {
|
|
@@ -217,7 +222,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
217
222
|
class="chart-area"
|
|
218
223
|
[attr.d]="s.areaPath"
|
|
219
224
|
[attr.fill]="areaFill(s.seriesKey, s.color)"
|
|
220
|
-
stroke="none"
|
|
225
|
+
stroke="none"
|
|
226
|
+
/>
|
|
221
227
|
<svg:path
|
|
222
228
|
class="chart-area-stroke"
|
|
223
229
|
[attr.d]="s.linePath"
|
|
@@ -225,7 +231,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
225
231
|
[attr.stroke-width]="strokeWidth()"
|
|
226
232
|
fill="none"
|
|
227
233
|
stroke-linecap="round"
|
|
228
|
-
stroke-linejoin="round"
|
|
234
|
+
stroke-linejoin="round"
|
|
235
|
+
/>
|
|
229
236
|
@if (showDots()) {
|
|
230
237
|
@for (p of s.points; track p.datumIndex) {
|
|
231
238
|
<svg:circle
|
|
@@ -235,12 +242,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
235
242
|
[attr.r]="dotRadius()"
|
|
236
243
|
[attr.fill]="s.color"
|
|
237
244
|
[attr.aria-label]="pointAriaLabel(p)"
|
|
245
|
+
role="img"
|
|
238
246
|
tabindex="0"
|
|
239
247
|
(focus)="setActivePoint($event, p)"
|
|
240
248
|
(blur)="clearActivePoint()"
|
|
241
249
|
(click)="emitClick(p)"
|
|
242
250
|
(keydown.enter)="emitClick(p)"
|
|
243
|
-
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
251
|
+
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
252
|
+
/>
|
|
244
253
|
}
|
|
245
254
|
}
|
|
246
255
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, output, computed, effect,
|
|
2
|
+
import { inject, input, output, computed, effect, Component } from '@angular/core';
|
|
3
3
|
import { seriesColorVar, ChartContext, CartesianContext, ChartThemeRadius, elementClientCenter } from '@ojiepermana/angular-chart/core';
|
|
4
4
|
import { scaleBand, scaleLinear } from 'd3-scale';
|
|
5
5
|
import { min, max } from 'd3-array';
|
|
@@ -414,7 +414,7 @@ class BarChart {
|
|
|
414
414
|
});
|
|
415
415
|
}, /* @ts-ignore */
|
|
416
416
|
...(ngDevMode ? [{ debugName: "dotLayout" }] : /* istanbul ignore next */ []));
|
|
417
|
-
dotTrackCells = computed(() =>
|
|
417
|
+
dotTrackCells = computed(() => this.showDotTrack() ? (this.dotLayout()?.track ?? []) : [], /* @ts-ignore */
|
|
418
418
|
...(ngDevMode ? [{ debugName: "dotTrackCells" }] : /* istanbul ignore next */ []));
|
|
419
419
|
dotValueCells = computed(() => this.dotLayout()?.values ?? [], /* @ts-ignore */
|
|
420
420
|
...(ngDevMode ? [{ debugName: "dotValueCells" }] : /* istanbul ignore next */ []));
|
|
@@ -534,7 +534,8 @@ class BarChart {
|
|
|
534
534
|
[attr.viewBox]="viewBox()"
|
|
535
535
|
preserveAspectRatio="none"
|
|
536
536
|
role="img"
|
|
537
|
-
[attr.aria-label]="ariaSummary()"
|
|
537
|
+
[attr.aria-label]="ariaSummary()"
|
|
538
|
+
>
|
|
538
539
|
<svg:g [attr.transform]="innerTransform()">
|
|
539
540
|
<ng-content select="svg\\:g[ChartGrid]" />
|
|
540
541
|
<svg:g class="chart-bars">
|
|
@@ -549,7 +550,8 @@ class BarChart {
|
|
|
549
550
|
[attr.height]="cell.height"
|
|
550
551
|
[attr.rx]="resolvedDotCornerRadius()"
|
|
551
552
|
[attr.ry]="resolvedDotCornerRadius()"
|
|
552
|
-
fill="hsl(var(--muted))"
|
|
553
|
+
fill="hsl(var(--muted))"
|
|
554
|
+
/>
|
|
553
555
|
}
|
|
554
556
|
@for (cell of dotValueCells(); track cell.key) {
|
|
555
557
|
<svg:rect
|
|
@@ -561,7 +563,8 @@ class BarChart {
|
|
|
561
563
|
[attr.rx]="resolvedDotCornerRadius()"
|
|
562
564
|
[attr.ry]="resolvedDotCornerRadius()"
|
|
563
565
|
[attr.fill]="cell.color"
|
|
564
|
-
[attr.opacity]="dotCellOpacity(cell)"
|
|
566
|
+
[attr.opacity]="dotCellOpacity(cell)"
|
|
567
|
+
/>
|
|
565
568
|
}
|
|
566
569
|
</svg:g>
|
|
567
570
|
}
|
|
@@ -579,20 +582,23 @@ class BarChart {
|
|
|
579
582
|
[attr.stroke]="bar.active ? 'hsl(var(--foreground))' : null"
|
|
580
583
|
[attr.stroke-width]="bar.active ? 1.5 : null"
|
|
581
584
|
[attr.aria-label]="barAriaLabel(bar)"
|
|
585
|
+
role="img"
|
|
582
586
|
tabindex="0"
|
|
583
587
|
(focus)="setActivePoint($event, bar)"
|
|
584
588
|
(blur)="clearActivePoint()"
|
|
585
589
|
(click)="emitClick(bar)"
|
|
586
590
|
(keydown.enter)="emitClick(bar)"
|
|
587
591
|
(keydown.space)="emitClick(bar); $event.preventDefault()"
|
|
588
|
-
(keydown)="onKeydown($event, idx)"
|
|
592
|
+
(keydown)="onKeydown($event, idx)"
|
|
593
|
+
/>
|
|
589
594
|
@if (showValueLabels() && bar.height > 0 && bar.width > 0) {
|
|
590
595
|
<svg:text
|
|
591
596
|
class="chart-bar-value pointer-events-none fill-muted-foreground text-2xs"
|
|
592
597
|
[attr.x]="barLabelX(bar)"
|
|
593
598
|
[attr.y]="barLabelY(bar)"
|
|
594
599
|
[attr.text-anchor]="barLabelAnchor(bar)"
|
|
595
|
-
dominant-baseline="middle"
|
|
600
|
+
dominant-baseline="middle"
|
|
601
|
+
>
|
|
596
602
|
{{ formatValueLabel(bar) }}
|
|
597
603
|
</svg:text>
|
|
598
604
|
}
|
|
@@ -627,13 +633,12 @@ class BarChart {
|
|
|
627
633
|
}
|
|
628
634
|
</tbody>
|
|
629
635
|
</table>
|
|
630
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }]
|
|
636
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }] });
|
|
631
637
|
}
|
|
632
638
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: BarChart, decorators: [{
|
|
633
639
|
type: Component,
|
|
634
640
|
args: [{
|
|
635
641
|
selector: 'ChartBar',
|
|
636
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
637
642
|
providers: [CartesianContext],
|
|
638
643
|
imports: [ChartPointerTracker],
|
|
639
644
|
host: { class: 'relative block h-full w-full', '[attr.data-style]': 'styles()' },
|
|
@@ -644,7 +649,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
644
649
|
[attr.viewBox]="viewBox()"
|
|
645
650
|
preserveAspectRatio="none"
|
|
646
651
|
role="img"
|
|
647
|
-
[attr.aria-label]="ariaSummary()"
|
|
652
|
+
[attr.aria-label]="ariaSummary()"
|
|
653
|
+
>
|
|
648
654
|
<svg:g [attr.transform]="innerTransform()">
|
|
649
655
|
<ng-content select="svg\\:g[ChartGrid]" />
|
|
650
656
|
<svg:g class="chart-bars">
|
|
@@ -659,7 +665,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
659
665
|
[attr.height]="cell.height"
|
|
660
666
|
[attr.rx]="resolvedDotCornerRadius()"
|
|
661
667
|
[attr.ry]="resolvedDotCornerRadius()"
|
|
662
|
-
fill="hsl(var(--muted))"
|
|
668
|
+
fill="hsl(var(--muted))"
|
|
669
|
+
/>
|
|
663
670
|
}
|
|
664
671
|
@for (cell of dotValueCells(); track cell.key) {
|
|
665
672
|
<svg:rect
|
|
@@ -671,7 +678,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
671
678
|
[attr.rx]="resolvedDotCornerRadius()"
|
|
672
679
|
[attr.ry]="resolvedDotCornerRadius()"
|
|
673
680
|
[attr.fill]="cell.color"
|
|
674
|
-
[attr.opacity]="dotCellOpacity(cell)"
|
|
681
|
+
[attr.opacity]="dotCellOpacity(cell)"
|
|
682
|
+
/>
|
|
675
683
|
}
|
|
676
684
|
</svg:g>
|
|
677
685
|
}
|
|
@@ -689,20 +697,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
689
697
|
[attr.stroke]="bar.active ? 'hsl(var(--foreground))' : null"
|
|
690
698
|
[attr.stroke-width]="bar.active ? 1.5 : null"
|
|
691
699
|
[attr.aria-label]="barAriaLabel(bar)"
|
|
700
|
+
role="img"
|
|
692
701
|
tabindex="0"
|
|
693
702
|
(focus)="setActivePoint($event, bar)"
|
|
694
703
|
(blur)="clearActivePoint()"
|
|
695
704
|
(click)="emitClick(bar)"
|
|
696
705
|
(keydown.enter)="emitClick(bar)"
|
|
697
706
|
(keydown.space)="emitClick(bar); $event.preventDefault()"
|
|
698
|
-
(keydown)="onKeydown($event, idx)"
|
|
707
|
+
(keydown)="onKeydown($event, idx)"
|
|
708
|
+
/>
|
|
699
709
|
@if (showValueLabels() && bar.height > 0 && bar.width > 0) {
|
|
700
710
|
<svg:text
|
|
701
711
|
class="chart-bar-value pointer-events-none fill-muted-foreground text-2xs"
|
|
702
712
|
[attr.x]="barLabelX(bar)"
|
|
703
713
|
[attr.y]="barLabelY(bar)"
|
|
704
714
|
[attr.text-anchor]="barLabelAnchor(bar)"
|
|
705
|
-
dominant-baseline="middle"
|
|
715
|
+
dominant-baseline="middle"
|
|
716
|
+
>
|
|
706
717
|
{{ formatValueLabel(bar) }}
|
|
707
718
|
</svg:text>
|
|
708
719
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, computed, Injectable, inject, ElementRef, Renderer2, effect,
|
|
2
|
+
import { signal, computed, Injectable, inject, ElementRef, Renderer2, effect, Component, NgZone, PLATFORM_ID, DestroyRef, viewChild, input, afterNextRender, Service } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
4
4
|
import { scalePoint, scaleLinear, scaleBand } from 'd3-scale';
|
|
5
5
|
import { max } from 'd3-array';
|
|
@@ -140,13 +140,12 @@ class ChartStyle {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: ChartStyle, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
143
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.4", type: ChartStyle, isStandalone: true, selector: "ChartStyle", ngImport: i0, template: '', isInline: true
|
|
143
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.4", type: ChartStyle, isStandalone: true, selector: "ChartStyle", ngImport: i0, template: '', isInline: true });
|
|
144
144
|
}
|
|
145
145
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: ChartStyle, decorators: [{
|
|
146
146
|
type: Component,
|
|
147
147
|
args: [{
|
|
148
148
|
selector: 'ChartStyle',
|
|
149
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
150
149
|
template: '',
|
|
151
150
|
}]
|
|
152
151
|
}], ctorParameters: () => [] });
|
|
@@ -232,13 +231,12 @@ class ChartContainer {
|
|
|
232
231
|
<ng-content />
|
|
233
232
|
</div>
|
|
234
233
|
<ng-content select="ChartLegend" />
|
|
235
|
-
`, isInline: true, dependencies: [{ kind: "component", type: ChartStyle, selector: "ChartStyle" }]
|
|
234
|
+
`, isInline: true, dependencies: [{ kind: "component", type: ChartStyle, selector: "ChartStyle" }] });
|
|
236
235
|
}
|
|
237
236
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: ChartContainer, decorators: [{
|
|
238
237
|
type: Component,
|
|
239
238
|
args: [{
|
|
240
239
|
selector: 'Chart',
|
|
241
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
242
240
|
providers: [ChartContext],
|
|
243
241
|
imports: [ChartStyle],
|
|
244
242
|
host: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, output, computed, effect,
|
|
2
|
+
import { inject, input, output, computed, effect, Component } from '@angular/core';
|
|
3
3
|
import { ChartContext, CartesianContext, CategoricalViewportContext, sliceByIndexRange, computeLineLayout, provideCartesianFromLineLayout, elementClientCenter } from '@ojiepermana/angular-chart/core';
|
|
4
4
|
export { buildCartesianScales, cloneLinear, computeAreaLayout, computeLineLayout, pointToBandAdapter, provideCartesianFromLineLayout } from '@ojiepermana/angular-chart/core';
|
|
5
5
|
import { ChartPointerTracker } from '@ojiepermana/angular-chart/primitives';
|
|
@@ -146,7 +146,8 @@ class LineChart {
|
|
|
146
146
|
[attr.viewBox]="viewBox()"
|
|
147
147
|
preserveAspectRatio="none"
|
|
148
148
|
role="img"
|
|
149
|
-
[attr.aria-label]="ariaSummary()"
|
|
149
|
+
[attr.aria-label]="ariaSummary()"
|
|
150
|
+
>
|
|
150
151
|
<svg:g [attr.transform]="innerTransform()">
|
|
151
152
|
<ng-content select="svg\\:g[ChartGrid]" />
|
|
152
153
|
<svg:g class="chart-lines">
|
|
@@ -158,7 +159,8 @@ class LineChart {
|
|
|
158
159
|
stroke-linejoin="round"
|
|
159
160
|
[attr.stroke]="s.color"
|
|
160
161
|
[attr.stroke-width]="strokeWidth()"
|
|
161
|
-
[attr.d]="s.linePath"
|
|
162
|
+
[attr.d]="s.linePath"
|
|
163
|
+
/>
|
|
162
164
|
@if (showDots()) {
|
|
163
165
|
@for (p of s.points; track p.datumIndex) {
|
|
164
166
|
<svg:circle
|
|
@@ -170,19 +172,22 @@ class LineChart {
|
|
|
170
172
|
[attr.stroke]="dotStrokeColor()"
|
|
171
173
|
[attr.stroke-width]="dotStrokeWidth() || null"
|
|
172
174
|
[attr.aria-label]="pointAriaLabel(p)"
|
|
175
|
+
role="img"
|
|
173
176
|
tabindex="0"
|
|
174
177
|
(focus)="setActivePoint($event, p)"
|
|
175
178
|
(blur)="clearActivePoint()"
|
|
176
179
|
(click)="emitClick(p)"
|
|
177
180
|
(keydown.enter)="emitClick(p)"
|
|
178
|
-
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
181
|
+
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
182
|
+
/>
|
|
179
183
|
@if (showValueLabels()) {
|
|
180
184
|
<svg:text
|
|
181
185
|
class="chart-line-value pointer-events-none fill-muted-foreground text-2xs"
|
|
182
186
|
[attr.x]="labelX(p)"
|
|
183
187
|
[attr.y]="labelY(p)"
|
|
184
188
|
[attr.text-anchor]="labelAnchor()"
|
|
185
|
-
dominant-baseline="middle"
|
|
189
|
+
dominant-baseline="middle"
|
|
190
|
+
>
|
|
186
191
|
{{ formatValueLabel(p) }}
|
|
187
192
|
</svg:text>
|
|
188
193
|
}
|
|
@@ -199,13 +204,12 @@ class LineChart {
|
|
|
199
204
|
<ng-content select="ChartTooltip" />
|
|
200
205
|
<ng-content select="ChartLegend" />
|
|
201
206
|
<ng-content select="ChartZoomControls" />
|
|
202
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }]
|
|
207
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: ChartPointerTracker, selector: "svg:svg[ChartPointerTracker]" }] });
|
|
203
208
|
}
|
|
204
209
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: LineChart, decorators: [{
|
|
205
210
|
type: Component,
|
|
206
211
|
args: [{
|
|
207
212
|
selector: 'ChartLine',
|
|
208
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
209
213
|
providers: [CartesianContext, CategoricalViewportContext],
|
|
210
214
|
imports: [ChartPointerTracker],
|
|
211
215
|
host: { class: 'relative block h-full w-full', '[attr.data-style]': 'styles()' },
|
|
@@ -216,7 +220,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
216
220
|
[attr.viewBox]="viewBox()"
|
|
217
221
|
preserveAspectRatio="none"
|
|
218
222
|
role="img"
|
|
219
|
-
[attr.aria-label]="ariaSummary()"
|
|
223
|
+
[attr.aria-label]="ariaSummary()"
|
|
224
|
+
>
|
|
220
225
|
<svg:g [attr.transform]="innerTransform()">
|
|
221
226
|
<ng-content select="svg\\:g[ChartGrid]" />
|
|
222
227
|
<svg:g class="chart-lines">
|
|
@@ -228,7 +233,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
228
233
|
stroke-linejoin="round"
|
|
229
234
|
[attr.stroke]="s.color"
|
|
230
235
|
[attr.stroke-width]="strokeWidth()"
|
|
231
|
-
[attr.d]="s.linePath"
|
|
236
|
+
[attr.d]="s.linePath"
|
|
237
|
+
/>
|
|
232
238
|
@if (showDots()) {
|
|
233
239
|
@for (p of s.points; track p.datumIndex) {
|
|
234
240
|
<svg:circle
|
|
@@ -240,19 +246,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
240
246
|
[attr.stroke]="dotStrokeColor()"
|
|
241
247
|
[attr.stroke-width]="dotStrokeWidth() || null"
|
|
242
248
|
[attr.aria-label]="pointAriaLabel(p)"
|
|
249
|
+
role="img"
|
|
243
250
|
tabindex="0"
|
|
244
251
|
(focus)="setActivePoint($event, p)"
|
|
245
252
|
(blur)="clearActivePoint()"
|
|
246
253
|
(click)="emitClick(p)"
|
|
247
254
|
(keydown.enter)="emitClick(p)"
|
|
248
|
-
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
255
|
+
(keydown.space)="emitClick(p); $event.preventDefault()"
|
|
256
|
+
/>
|
|
249
257
|
@if (showValueLabels()) {
|
|
250
258
|
<svg:text
|
|
251
259
|
class="chart-line-value pointer-events-none fill-muted-foreground text-2xs"
|
|
252
260
|
[attr.x]="labelX(p)"
|
|
253
261
|
[attr.y]="labelY(p)"
|
|
254
262
|
[attr.text-anchor]="labelAnchor()"
|
|
255
|
-
dominant-baseline="middle"
|
|
263
|
+
dominant-baseline="middle"
|
|
264
|
+
>
|
|
256
265
|
{{ formatValueLabel(p) }}
|
|
257
266
|
</svg:text>
|
|
258
267
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pie, arc } from 'd3-shape';
|
|
2
2
|
import { seriesColorVar, ChartContext, ChartThemeRadius } from '@ojiepermana/angular-chart/core';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { inject, input, output, computed,
|
|
4
|
+
import { inject, input, output, computed, Component } from '@angular/core';
|
|
5
5
|
|
|
6
6
|
function computePieLayout(input) {
|
|
7
7
|
const { data, valueKey, nameKey, seriesKeys, innerWidth, innerHeight, innerRadius, padAngle, cornerRadius, startAngle, endAngle, activeIndex, activeOffset = 12, } = input;
|
|
@@ -125,8 +125,12 @@ class PieChart {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
setActive(event, s) {
|
|
128
|
-
const clientX = event instanceof PointerEvent
|
|
129
|
-
|
|
128
|
+
const clientX = event instanceof PointerEvent
|
|
129
|
+
? event.clientX
|
|
130
|
+
: event.target.getBoundingClientRect().left;
|
|
131
|
+
const clientY = event instanceof PointerEvent
|
|
132
|
+
? event.clientY
|
|
133
|
+
: event.target.getBoundingClientRect().top;
|
|
130
134
|
this.root.activePoint.set({
|
|
131
135
|
index: s.datumIndex,
|
|
132
136
|
datumIndex: s.datumIndex,
|
|
@@ -145,7 +149,8 @@ class PieChart {
|
|
|
145
149
|
[attr.viewBox]="viewBox()"
|
|
146
150
|
preserveAspectRatio="xMidYMid meet"
|
|
147
151
|
role="img"
|
|
148
|
-
[attr.aria-label]="ariaSummary()"
|
|
152
|
+
[attr.aria-label]="ariaSummary()"
|
|
153
|
+
>
|
|
149
154
|
<svg:g [attr.transform]="innerTransform()">
|
|
150
155
|
<svg:g [attr.transform]="'translate(' + layout().centerX + ',' + layout().centerY + ')'">
|
|
151
156
|
@for (s of layout().slices; track s.seriesKey) {
|
|
@@ -155,6 +160,7 @@ class PieChart {
|
|
|
155
160
|
[attr.fill]="s.color"
|
|
156
161
|
[attr.transform]="sliceTransform(s)"
|
|
157
162
|
[attr.aria-label]="sliceAriaLabel(s)"
|
|
163
|
+
role="img"
|
|
158
164
|
tabindex="0"
|
|
159
165
|
(click)="emitClick(s)"
|
|
160
166
|
(keydown.enter)="emitClick(s)"
|
|
@@ -163,7 +169,8 @@ class PieChart {
|
|
|
163
169
|
(pointermove)="setActive($event, s)"
|
|
164
170
|
(pointerleave)="clearActive()"
|
|
165
171
|
(focus)="setActive($event, s)"
|
|
166
|
-
(blur)="clearActive()"
|
|
172
|
+
(blur)="clearActive()"
|
|
173
|
+
/>
|
|
167
174
|
}
|
|
168
175
|
@if (showLabels()) {
|
|
169
176
|
@for (s of layout().slices; track s.seriesKey) {
|
|
@@ -172,7 +179,8 @@ class PieChart {
|
|
|
172
179
|
text-anchor="middle"
|
|
173
180
|
dominant-baseline="middle"
|
|
174
181
|
[attr.x]="s.centroid[0] + s.translateX"
|
|
175
|
-
[attr.y]="s.centroid[1] + s.translateY"
|
|
182
|
+
[attr.y]="s.centroid[1] + s.translateY"
|
|
183
|
+
>
|
|
176
184
|
{{ s.value }}
|
|
177
185
|
</svg:text>
|
|
178
186
|
}
|
|
@@ -185,13 +193,12 @@ class PieChart {
|
|
|
185
193
|
</div>
|
|
186
194
|
<ng-content select="ChartTooltip" />
|
|
187
195
|
<ng-content select="ChartLegend" />
|
|
188
|
-
`, isInline: true
|
|
196
|
+
`, isInline: true });
|
|
189
197
|
}
|
|
190
198
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImport: i0, type: PieChart, decorators: [{
|
|
191
199
|
type: Component,
|
|
192
200
|
args: [{
|
|
193
201
|
selector: 'ChartPie',
|
|
194
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
195
202
|
host: { class: 'relative block h-full w-full', '[attr.data-style]': 'styles()' },
|
|
196
203
|
template: `
|
|
197
204
|
<svg:svg
|
|
@@ -199,7 +206,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
199
206
|
[attr.viewBox]="viewBox()"
|
|
200
207
|
preserveAspectRatio="xMidYMid meet"
|
|
201
208
|
role="img"
|
|
202
|
-
[attr.aria-label]="ariaSummary()"
|
|
209
|
+
[attr.aria-label]="ariaSummary()"
|
|
210
|
+
>
|
|
203
211
|
<svg:g [attr.transform]="innerTransform()">
|
|
204
212
|
<svg:g [attr.transform]="'translate(' + layout().centerX + ',' + layout().centerY + ')'">
|
|
205
213
|
@for (s of layout().slices; track s.seriesKey) {
|
|
@@ -209,6 +217,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
209
217
|
[attr.fill]="s.color"
|
|
210
218
|
[attr.transform]="sliceTransform(s)"
|
|
211
219
|
[attr.aria-label]="sliceAriaLabel(s)"
|
|
220
|
+
role="img"
|
|
212
221
|
tabindex="0"
|
|
213
222
|
(click)="emitClick(s)"
|
|
214
223
|
(keydown.enter)="emitClick(s)"
|
|
@@ -217,7 +226,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
217
226
|
(pointermove)="setActive($event, s)"
|
|
218
227
|
(pointerleave)="clearActive()"
|
|
219
228
|
(focus)="setActive($event, s)"
|
|
220
|
-
(blur)="clearActive()"
|
|
229
|
+
(blur)="clearActive()"
|
|
230
|
+
/>
|
|
221
231
|
}
|
|
222
232
|
@if (showLabels()) {
|
|
223
233
|
@for (s of layout().slices; track s.seriesKey) {
|
|
@@ -226,7 +236,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.4", ngImpor
|
|
|
226
236
|
text-anchor="middle"
|
|
227
237
|
dominant-baseline="middle"
|
|
228
238
|
[attr.x]="s.centroid[0] + s.translateX"
|
|
229
|
-
[attr.y]="s.centroid[1] + s.translateY"
|
|
239
|
+
[attr.y]="s.centroid[1] + s.translateY"
|
|
240
|
+
>
|
|
230
241
|
{{ s.value }}
|
|
231
242
|
</svg:text>
|
|
232
243
|
}
|