@bizy/core 20.3.1 → 20.3.2
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/bizy-core.mjs +75 -43
- package/fesm2022/bizy-core.mjs.map +1 -1
- package/index.d.ts +11 -2
- package/package.json +1 -1
- package/styles/variables.css +7 -0
package/fesm2022/bizy-core.mjs
CHANGED
|
@@ -313,7 +313,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
|
|
|
313
313
|
}]
|
|
314
314
|
}] });
|
|
315
315
|
|
|
316
|
-
const MIN_CHART_SIZE
|
|
316
|
+
const MIN_CHART_SIZE = 350; // px;
|
|
317
317
|
const Y_AXIS_OFFSET = 80;
|
|
318
318
|
const GRID_BOTTOM = 30;
|
|
319
319
|
class BizyBarLineChartComponent {
|
|
@@ -592,10 +592,10 @@ class BizyBarLineChartComponent {
|
|
|
592
592
|
if (this.#chartContainer || !this.#elementRef || !this.#elementRef.nativeElement) {
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
|
-
let elementWidth = this.#elementRef.nativeElement.offsetWidth || MIN_CHART_SIZE
|
|
596
|
-
let elementHeight = this.#elementRef.nativeElement.offsetHeight || MIN_CHART_SIZE
|
|
597
|
-
let minWidth = MIN_CHART_SIZE
|
|
598
|
-
let minHeight = MIN_CHART_SIZE
|
|
595
|
+
let elementWidth = this.#elementRef.nativeElement.offsetWidth || MIN_CHART_SIZE;
|
|
596
|
+
let elementHeight = this.#elementRef.nativeElement.offsetHeight || MIN_CHART_SIZE;
|
|
597
|
+
let minWidth = MIN_CHART_SIZE;
|
|
598
|
+
let minHeight = MIN_CHART_SIZE;
|
|
599
599
|
const barChartMinWidth = getComputedStyle(this.#document.body).getPropertyValue('--bizy-chart-min-width');
|
|
600
600
|
const barChartMinHeight = getComputedStyle(this.#document.body).getPropertyValue('--bizy-chart-min-height');
|
|
601
601
|
if (Number(barChartMinWidth)) {
|
|
@@ -3350,7 +3350,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
|
|
|
3350
3350
|
}] });
|
|
3351
3351
|
|
|
3352
3352
|
const EMPTY_CHART = [0];
|
|
3353
|
-
const
|
|
3353
|
+
const DEFAULT_CHART_SIZE = '300px';
|
|
3354
3354
|
class BizyPieChartComponent {
|
|
3355
3355
|
#elementRef = inject(ElementRef);
|
|
3356
3356
|
#document = inject(DOCUMENT);
|
|
@@ -3358,14 +3358,15 @@ class BizyPieChartComponent {
|
|
|
3358
3358
|
#renderer = inject(Renderer2);
|
|
3359
3359
|
resizeRef = null;
|
|
3360
3360
|
tooltip = true;
|
|
3361
|
+
centerLabel = null;
|
|
3361
3362
|
type = 'pie';
|
|
3362
|
-
|
|
3363
|
+
legend = null;
|
|
3364
|
+
download = { show: true, label: 'Descargar', name: 'Bizy' };
|
|
3363
3365
|
onLabelFormatter;
|
|
3364
3366
|
onTooltipFormatter;
|
|
3365
3367
|
onSelect = new EventEmitter();
|
|
3366
3368
|
onDownload = new EventEmitter();
|
|
3367
3369
|
#echarts = null;
|
|
3368
|
-
#mutationObserver = null;
|
|
3369
3370
|
#resizeObserver = null;
|
|
3370
3371
|
#subscription = new Subscription();
|
|
3371
3372
|
#chartContainer = null;
|
|
@@ -3373,13 +3374,7 @@ class BizyPieChartComponent {
|
|
|
3373
3374
|
#resize$ = new Subject();
|
|
3374
3375
|
#data = EMPTY_CHART;
|
|
3375
3376
|
ngAfterViewInit() {
|
|
3376
|
-
this.#
|
|
3377
|
-
if (this.#elementRef && this.#elementRef.nativeElement && (this.#elementRef.nativeElement.offsetWidth || this.#elementRef.nativeElement.offsetHeight)) {
|
|
3378
|
-
this.#afterViewInit.next(true);
|
|
3379
|
-
this.#mutationObserver.disconnect();
|
|
3380
|
-
}
|
|
3381
|
-
});
|
|
3382
|
-
this.#mutationObserver.observe(this.#document.body, { childList: true, subtree: true });
|
|
3377
|
+
this.#afterViewInit.next(true);
|
|
3383
3378
|
}
|
|
3384
3379
|
getNativeElement = () => this.#elementRef?.nativeElement;
|
|
3385
3380
|
set data(data) {
|
|
@@ -3444,26 +3439,26 @@ class BizyPieChartComponent {
|
|
|
3444
3439
|
const label = this.type === 'pie' ? undefined : { show: false, position: 'center' };
|
|
3445
3440
|
const series = [{
|
|
3446
3441
|
type: 'pie',
|
|
3447
|
-
radius: this.type === 'pie' ? '50%' : ['
|
|
3442
|
+
radius: this.type === 'pie' ? '50%' : ['50%', '70%'],
|
|
3448
3443
|
center: ['50%', '50%'],
|
|
3449
3444
|
data: this.#data,
|
|
3450
3445
|
itemStyle,
|
|
3451
3446
|
label
|
|
3452
3447
|
}];
|
|
3453
|
-
const textColor =
|
|
3454
|
-
const textBackgroundColor =
|
|
3455
|
-
const borderColor =
|
|
3448
|
+
const textColor = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-tooltip-color');
|
|
3449
|
+
const textBackgroundColor = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-tooltip-background-color');
|
|
3450
|
+
const borderColor = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-tooltip-border-color');
|
|
3456
3451
|
const toolbox = {
|
|
3457
3452
|
show: true,
|
|
3458
3453
|
feature: {
|
|
3459
3454
|
mySaveAsImage: {
|
|
3460
|
-
show:
|
|
3455
|
+
show: this.download.show,
|
|
3461
3456
|
icon: 'path://M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z',
|
|
3462
3457
|
title: this.download.label,
|
|
3463
3458
|
onclick: () => {
|
|
3464
3459
|
setTimeout(() => {
|
|
3465
3460
|
html2canvas(this.#chartContainer).then(canvas => {
|
|
3466
|
-
var link =
|
|
3461
|
+
var link = this.#renderer.createElement('a');
|
|
3467
3462
|
link.href = canvas.toDataURL('image/png');
|
|
3468
3463
|
link.download = `${this.download.name}.png`;
|
|
3469
3464
|
this.#renderer.appendChild(this.#document.body, link);
|
|
@@ -3491,12 +3486,45 @@ class BizyPieChartComponent {
|
|
|
3491
3486
|
appendToBody: true,
|
|
3492
3487
|
formatter: this.onTooltipFormatter
|
|
3493
3488
|
};
|
|
3494
|
-
|
|
3489
|
+
let legend = {};
|
|
3490
|
+
if (this.legend) {
|
|
3491
|
+
legend.show = this.legend.show;
|
|
3492
|
+
legend.orient = this.legend.orient;
|
|
3493
|
+
legend.left = this.legend.position ? this.legend.position.x : 'auto';
|
|
3494
|
+
legend.top = this.legend.position ? this.legend.position.y : 'auto';
|
|
3495
|
+
}
|
|
3496
|
+
else {
|
|
3497
|
+
legend = this.type === 'pie' ? { show: false } : {
|
|
3498
|
+
show: true,
|
|
3499
|
+
orient: 'vertical',
|
|
3500
|
+
left: 'left'
|
|
3501
|
+
};
|
|
3502
|
+
}
|
|
3503
|
+
let graphic;
|
|
3504
|
+
if (this.centerLabel) {
|
|
3505
|
+
let centerLabelColor = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-center-label-color');
|
|
3506
|
+
let { width, height } = this.#chartContainer.getBoundingClientRect();
|
|
3507
|
+
let base = Math.min(width, height);
|
|
3508
|
+
let fontSize = base / 6;
|
|
3509
|
+
graphic = {
|
|
3510
|
+
type: 'text',
|
|
3511
|
+
left: 'center',
|
|
3512
|
+
top: 'center',
|
|
3513
|
+
style: {
|
|
3514
|
+
text: this.centerLabel,
|
|
3515
|
+
fill: centerLabelColor,
|
|
3516
|
+
textAlign: 'center',
|
|
3517
|
+
fontSize,
|
|
3518
|
+
fontWeight: 'bold'
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
}
|
|
3495
3522
|
const option = {
|
|
3496
3523
|
tooltip,
|
|
3497
3524
|
toolbox,
|
|
3498
3525
|
legend,
|
|
3499
|
-
series
|
|
3526
|
+
series,
|
|
3527
|
+
graphic
|
|
3500
3528
|
};
|
|
3501
3529
|
import('echarts').then(echarts => {
|
|
3502
3530
|
this.#echarts = echarts.init(this.#chartContainer);
|
|
@@ -3526,23 +3554,15 @@ class BizyPieChartComponent {
|
|
|
3526
3554
|
if (this.#chartContainer || !this.#elementRef || !this.#elementRef.nativeElement) {
|
|
3527
3555
|
return;
|
|
3528
3556
|
}
|
|
3529
|
-
let elementWidth = this.#elementRef.nativeElement.offsetWidth
|
|
3530
|
-
let elementHeight = this.#elementRef.nativeElement.offsetHeight
|
|
3531
|
-
let minWidth =
|
|
3532
|
-
let minHeight =
|
|
3533
|
-
const
|
|
3534
|
-
const
|
|
3535
|
-
if (Number(chartMinWidth)) {
|
|
3536
|
-
minWidth = Number(chartMinWidth);
|
|
3537
|
-
}
|
|
3538
|
-
if (Number(pieChartMinHeight)) {
|
|
3539
|
-
minHeight = Number(pieChartMinHeight);
|
|
3540
|
-
}
|
|
3541
|
-
const width = Math.max(elementWidth, minWidth);
|
|
3542
|
-
const height = Math.max(elementHeight, minHeight);
|
|
3557
|
+
let elementWidth = this.#elementRef.nativeElement.offsetWidth;
|
|
3558
|
+
let elementHeight = this.#elementRef.nativeElement.offsetHeight;
|
|
3559
|
+
let minWidth = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-width');
|
|
3560
|
+
let minHeight = this.#getClosestCssVariable(this.#elementRef.nativeElement, '--bizy-pie-chart-height');
|
|
3561
|
+
const width = minWidth ? minWidth : elementWidth ? `${elementWidth}px` : DEFAULT_CHART_SIZE;
|
|
3562
|
+
const height = minHeight ? minHeight : elementHeight ? `${elementHeight}px` : DEFAULT_CHART_SIZE;
|
|
3543
3563
|
this.#chartContainer = this.#renderer.createElement('div');
|
|
3544
|
-
this.#renderer.setStyle(this.#chartContainer, 'width',
|
|
3545
|
-
this.#renderer.setStyle(this.#chartContainer, 'height',
|
|
3564
|
+
this.#renderer.setStyle(this.#chartContainer, 'width', width);
|
|
3565
|
+
this.#renderer.setStyle(this.#chartContainer, 'height', height);
|
|
3546
3566
|
this.#renderer.appendChild(this.#elementRef.nativeElement, this.#chartContainer);
|
|
3547
3567
|
this.#ref.detectChanges();
|
|
3548
3568
|
};
|
|
@@ -3555,11 +3575,19 @@ class BizyPieChartComponent {
|
|
|
3555
3575
|
this.#chartContainer = null;
|
|
3556
3576
|
this.#ref.detectChanges();
|
|
3557
3577
|
};
|
|
3578
|
+
#getClosestCssVariable = (element, cssVariable) => {
|
|
3579
|
+
while (element) {
|
|
3580
|
+
const value = getComputedStyle(element).getPropertyValue(cssVariable).trim();
|
|
3581
|
+
if (value) {
|
|
3582
|
+
return value;
|
|
3583
|
+
}
|
|
3584
|
+
element = element.parentElement;
|
|
3585
|
+
}
|
|
3586
|
+
const rootValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariable).trim();
|
|
3587
|
+
return rootValue || null;
|
|
3588
|
+
};
|
|
3558
3589
|
ngOnDestroy() {
|
|
3559
3590
|
this.#subscription.unsubscribe();
|
|
3560
|
-
if (this.#mutationObserver) {
|
|
3561
|
-
this.#mutationObserver.disconnect();
|
|
3562
|
-
}
|
|
3563
3591
|
if (this.#resizeObserver) {
|
|
3564
3592
|
this.#resizeObserver.disconnect();
|
|
3565
3593
|
}
|
|
@@ -3568,7 +3596,7 @@ class BizyPieChartComponent {
|
|
|
3568
3596
|
}
|
|
3569
3597
|
}
|
|
3570
3598
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: BizyPieChartComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3571
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.5", type: BizyPieChartComponent, isStandalone: true, selector: "bizy-pie-chart", inputs: { resizeRef: "resizeRef", tooltip: "tooltip", type: "type", download: "download", onLabelFormatter: "onLabelFormatter", onTooltipFormatter: "onTooltipFormatter", data: "data" }, outputs: { onSelect: "onSelect", onDownload: "onDownload" }, ngImport: i0, template: '', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3599
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.5", type: BizyPieChartComponent, isStandalone: true, selector: "bizy-pie-chart", inputs: { resizeRef: "resizeRef", tooltip: "tooltip", centerLabel: "centerLabel", type: "type", legend: "legend", download: "download", onLabelFormatter: "onLabelFormatter", onTooltipFormatter: "onTooltipFormatter", data: "data" }, outputs: { onSelect: "onSelect", onDownload: "onDownload" }, ngImport: i0, template: '', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3572
3600
|
}
|
|
3573
3601
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImport: i0, type: BizyPieChartComponent, decorators: [{
|
|
3574
3602
|
type: Component,
|
|
@@ -3582,8 +3610,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.5", ngImpor
|
|
|
3582
3610
|
type: Input
|
|
3583
3611
|
}], tooltip: [{
|
|
3584
3612
|
type: Input
|
|
3613
|
+
}], centerLabel: [{
|
|
3614
|
+
type: Input
|
|
3585
3615
|
}], type: [{
|
|
3586
3616
|
type: Input
|
|
3617
|
+
}], legend: [{
|
|
3618
|
+
type: Input
|
|
3587
3619
|
}], download: [{
|
|
3588
3620
|
type: Input
|
|
3589
3621
|
}], onLabelFormatter: [{
|