@tetacom/svg-charts 1.1.21 → 1.1.24
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/chart/chart/chart.component.d.ts +3 -3
- package/chart/chart-container/series/block-area-series/block-area-series.component.d.ts +1 -0
- package/chart/chart-container/series/block-series/block-series.component.d.ts +1 -0
- package/chart/directives/zoomable.directive.d.ts +2 -1
- package/esm2020/chart/chart/chart.component.mjs +6 -6
- package/esm2020/chart/chart-container/series/block-area-series/block-area-series.component.mjs +9 -11
- package/esm2020/chart/chart-container/series/block-series/block-series.component.mjs +8 -10
- package/esm2020/chart/chart-container/tooltip/tooltip.component.mjs +8 -2
- package/esm2020/chart/core/axis/axis.mjs +2 -2
- package/esm2020/chart/directives/brushable.directive.mjs +4 -2
- package/esm2020/chart/directives/zoomable.directive.mjs +118 -72
- package/esm2020/chart/service/chart.service.mjs +3 -1
- package/fesm2015/tetacom-svg-charts.mjs +148 -98
- package/fesm2015/tetacom-svg-charts.mjs.map +1 -1
- package/fesm2020/tetacom-svg-charts.mjs +146 -95
- package/fesm2020/tetacom-svg-charts.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -218,6 +218,7 @@ class ChartService {
|
|
|
218
218
|
config.series = config.series.map((_, index) => {
|
|
219
219
|
return {
|
|
220
220
|
..._,
|
|
221
|
+
data: _.data ?? [],
|
|
221
222
|
id: _.id ?? index,
|
|
222
223
|
};
|
|
223
224
|
});
|
|
@@ -238,6 +239,7 @@ class ChartService {
|
|
|
238
239
|
config.bounds.right = 0;
|
|
239
240
|
}
|
|
240
241
|
config.tooltip = Object.assign({}, defaultChartConfig().tooltip, config.tooltip);
|
|
242
|
+
config.zoom = Object.assign({}, defaultChartConfig().zoom, config.zoom);
|
|
241
243
|
config.zoom.syncChannel = config.zoom?.syncChannel ?? id;
|
|
242
244
|
return config;
|
|
243
245
|
}
|
|
@@ -381,7 +383,7 @@ class Axis {
|
|
|
381
383
|
this._extremes = [0, 0];
|
|
382
384
|
this.defaultFormatters = new Map()
|
|
383
385
|
.set(ScaleType.linear, d3.format(',.2f'))
|
|
384
|
-
.set(ScaleType.time, d3.timeFormat('%
|
|
386
|
+
.set(ScaleType.time, d3.timeFormat('%d.%m.%Y'))
|
|
385
387
|
.set(ScaleType.log, d3.format(',.2f'))
|
|
386
388
|
.set(ScaleType.pow, d3.format(',.2f'))
|
|
387
389
|
.set(ScaleType.sqrt, d3.format(',.2f'));
|
|
@@ -831,11 +833,16 @@ class TooltipComponent {
|
|
|
831
833
|
};
|
|
832
834
|
const defaultFormatter = (tooltips) => {
|
|
833
835
|
let html = '';
|
|
836
|
+
const format = d3.timeFormat('%d.%m.%Y');
|
|
834
837
|
tooltips.forEach((_) => {
|
|
835
838
|
const indicatorStyle = `display:block; width: 10px; height: 2px; background-color: ${_?.series?.color}`;
|
|
836
839
|
html += `<div class="display-flex align-center"><span class="margin-right-1" style="${indicatorStyle}"></span>
|
|
837
840
|
<span class="font-title-3">${_.series.name}
|
|
838
|
-
|
|
841
|
+
<span class="font-body-3">
|
|
842
|
+
x: ${_.point.x instanceof Date ? format(_.point.x) : _.point.x?.toFixed(2)}
|
|
843
|
+
y: ${_.point.y instanceof Date ? format(_.point.y) : _.point.y?.toFixed(2)}
|
|
844
|
+
</span>
|
|
845
|
+
</span></div>`;
|
|
839
846
|
});
|
|
840
847
|
return transformHtml(html);
|
|
841
848
|
};
|
|
@@ -1563,6 +1570,7 @@ class BlockSeriesComponent extends SeriesBaseComponent {
|
|
|
1563
1570
|
this.zoomService = zoomService;
|
|
1564
1571
|
this.element = element;
|
|
1565
1572
|
this.fillType = FillType;
|
|
1573
|
+
this.Math = Math;
|
|
1566
1574
|
this.id = (Date.now() + Math.random()).toString(36);
|
|
1567
1575
|
}
|
|
1568
1576
|
ngOnInit() {
|
|
@@ -1571,18 +1579,15 @@ class BlockSeriesComponent extends SeriesBaseComponent {
|
|
|
1571
1579
|
this.y = this.scaleService.yScaleMap.pipe(map((_) => _.get(this.series.yAxisIndex)));
|
|
1572
1580
|
this.displayPoints = this.y.pipe(map((y) => {
|
|
1573
1581
|
return this.series.data.filter((point, index, arr) => {
|
|
1574
|
-
const height = Math.abs(y(point.y1) - y(point.y));
|
|
1575
1582
|
const [min, max] = y.domain();
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
arr[index + 1]?.y1 >= min) &&
|
|
1583
|
+
return (point.y >= min ||
|
|
1584
|
+
point.y1 >= min ||
|
|
1585
|
+
arr[index + 1]?.y >= min ||
|
|
1586
|
+
arr[index + 1]?.y1 >= min) &&
|
|
1581
1587
|
(point.y <= max ||
|
|
1582
1588
|
point.y1 <= max ||
|
|
1583
1589
|
arr[index - 1]?.y <= max ||
|
|
1584
1590
|
arr[index - 1]?.y1 <= max);
|
|
1585
|
-
return visibleCondition;
|
|
1586
1591
|
});
|
|
1587
1592
|
}));
|
|
1588
1593
|
}
|
|
@@ -1602,10 +1607,10 @@ class BlockSeriesComponent extends SeriesBaseComponent {
|
|
|
1602
1607
|
}
|
|
1603
1608
|
}
|
|
1604
1609
|
BlockSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BlockSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1605
|
-
BlockSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: BlockSeriesComponent, selector: "svg:svg[teta-block-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"data.y(point.y1) - data.y(point.y)\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1610
|
+
BlockSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: BlockSeriesComponent, selector: "svg:svg[teta-block-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1606
1611
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BlockSeriesComponent, decorators: [{
|
|
1607
1612
|
type: Component,
|
|
1608
|
-
args: [{ selector: 'svg:svg[teta-block-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"data.y(point.y1) - data.y(point.y)\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""] }]
|
|
1613
|
+
args: [{ selector: 'svg:svg[teta-block-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\" gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n x=\"0\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\"\n width=\"100%\">\n </svg:rect>\n <svg:text *ngIf=\"point.text && data.y(point.y1) - data.y(point.y) > 8\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\"\n [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""] }]
|
|
1609
1614
|
}], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
|
|
1610
1615
|
|
|
1611
1616
|
class BlockAreaSeriesComponent extends SeriesBaseComponent {
|
|
@@ -1617,26 +1622,24 @@ class BlockAreaSeriesComponent extends SeriesBaseComponent {
|
|
|
1617
1622
|
this.zoomService = zoomService;
|
|
1618
1623
|
this.element = element;
|
|
1619
1624
|
this.fillType = FillType;
|
|
1625
|
+
this.Math = Math;
|
|
1620
1626
|
this.id = (Date.now() + Math.random()).toString(36);
|
|
1621
1627
|
}
|
|
1622
1628
|
ngOnInit() {
|
|
1623
|
-
const defaultVisiblePixels =
|
|
1629
|
+
const defaultVisiblePixels = 0;
|
|
1624
1630
|
this.x = this.scaleService.xScaleMap.pipe(map((_) => _.get(this.series.xAxisIndex)));
|
|
1625
1631
|
this.y = this.scaleService.yScaleMap.pipe(map((_) => _.get(this.series.yAxisIndex)));
|
|
1626
1632
|
this.displayPoints = this.y.pipe(map((y) => {
|
|
1627
1633
|
return this.series.data.filter((point, index, arr) => {
|
|
1628
|
-
const height = Math.abs(y(point.y1) - y(point.y));
|
|
1629
1634
|
const [min, max] = y.domain();
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
arr[index + 1]?.y1 >= min) &&
|
|
1635
|
+
return (point.y >= min ||
|
|
1636
|
+
point.y1 >= min ||
|
|
1637
|
+
arr[index + 1]?.y >= min ||
|
|
1638
|
+
arr[index + 1]?.y1 >= min) &&
|
|
1635
1639
|
(point.y <= max ||
|
|
1636
1640
|
point.y1 <= max ||
|
|
1637
1641
|
arr[index - 1]?.y <= max ||
|
|
1638
1642
|
arr[index - 1]?.y1 <= max);
|
|
1639
|
-
return visibleCondition;
|
|
1640
1643
|
});
|
|
1641
1644
|
}));
|
|
1642
1645
|
}
|
|
@@ -1656,10 +1659,10 @@ class BlockAreaSeriesComponent extends SeriesBaseComponent {
|
|
|
1656
1659
|
}
|
|
1657
1660
|
}
|
|
1658
1661
|
BlockAreaSeriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BlockAreaSeriesComponent, deps: [{ token: ChartService }, { token: i0.ChangeDetectorRef }, { token: ScaleService }, { token: ZoomService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
1659
|
-
BlockAreaSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: BlockAreaSeriesComponent, selector: "svg:svg[teta-block-area-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"data.y(point.y1) - data.y(point.y)\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"data.y(0) - data.y(point.y)\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1662
|
+
BlockAreaSeriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.1", type: BlockAreaSeriesComponent, selector: "svg:svg[teta-block-area-series]", usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"Math.abs(data.y(0) - data.y(point.y))\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i4.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1660
1663
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BlockAreaSeriesComponent, decorators: [{
|
|
1661
1664
|
type: Component,
|
|
1662
|
-
args: [{ selector: 'svg:svg[teta-block-area-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"data.y(point.y1) - data.y(point.y)\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"data.y(0) - data.y(point.y)\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""] }]
|
|
1665
|
+
args: [{ selector: 'svg:svg[teta-block-area-series]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{\n y: y | async,\n x: x | async,\n points: displayPoints | async\n} as data\">\n <svg:defs *ngIf=\"series?.fillType === fillType.gradient\">\n <svg:linearGradient [id]=\"'gradient-fill-' + id\"\n gradientUnits=\"userSpaceOnUse\"\n x1=\"0%\"\n [attr.y1]=\"config?.inverted ? '0%' : '100%'\"\n [attr.x2]=\"config?.inverted ? '100%' : '0%'\"\n y2=\"0%\">\n <svg:stop offset=\"0%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0\"></svg:stop>\n <svg:stop offset=\"5%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.1\"></svg:stop>\n <svg:stop offset=\"20%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.2\"></svg:stop>\n <svg:stop offset=\"60%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.5\"></svg:stop>\n <svg:stop offset=\"100%\" [attr.stop-color]=\"series.color\" stop-opacity=\"0.9\"></svg:stop>\n </svg:linearGradient>\n </svg:defs>\n <ng-container *ngFor=\"let point of data.points\">\n <svg:g (mouseenter)=\"mouseenter(point)\"\n (mouseleave)=\"mouseleave(point)\">\n <svg:rect\n *ngIf=\"!!config.inverted\"\n [attr.x]=\"data.x(0) < data.x(point.x) ? data.x(0) : data.x(point.x)\"\n [attr.y]=\"data.y(point.y)\"\n [attr.height]=\"Math.abs(data.y(point.y1) - data.y(point.y))\"\n [attr.width]=\"data.x(0) < data.x(point.x) ? data.x(point.x) - data.x(0) : data.x(0) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:rect\n *ngIf=\"!config.inverted\"\n [attr.x]=\"data.x(point.x)\"\n [attr.y]=\"data.y(0)\"\n [attr.height]=\"Math.abs(data.y(0) - data.y(point.y))\"\n [attr.width]=\"data.x(point.x1) - data.x(point.x)\"\n [attr.stroke]=\"point.iconId ? '' : point.color ?? series.color\"\n [attr.stroke-dasharray]=\"series.style?.strokeDasharray\"\n [attr.stroke-width]=\"series.style?.strokeWidth\"\n [attr.fill]=\"series.fillType === fillType.gradient ? 'url(#gradient-fill-'+id+')' : point.iconId ? 'url(#pattern'+point.iconId+')' : point.color ?? series.color\"\n [attr.fill-opacity]=\"series.style?.fillOpacity\">\n </svg:rect>\n <svg:text *ngIf=\"point.text\"\n x=\"50%\"\n [attr.y]=\"(data.y(point.y1) + data.y(point.y)) / 2\"\n alignment-baseline=\"middle\"\n text-anchor=\"middle\">{{ point.text }}\n </svg:text>\n\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y)\" [attr.y2]=\"data.y(point.y)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n <!-- <svg:line x1=\"0\" x2=\"100%\" [attr.y1]=\"data.y(point.y1)\" [attr.y2]=\"data.y(point.y1)\" [attr.stroke]=\"point.iconId ? 'var(--color-text-10)' : point.color ?? series.color\"></svg:line>-->\n\n </svg:g>\n </ng-container>\n\n\n</ng-container>\n", styles: [""] }]
|
|
1663
1666
|
}], ctorParameters: function () { return [{ type: ChartService }, { type: i0.ChangeDetectorRef }, { type: ScaleService }, { type: ZoomService }, { type: i0.ElementRef }]; } });
|
|
1664
1667
|
|
|
1665
1668
|
class AreaSeriesComponent extends LinearSeriesBase {
|
|
@@ -1837,6 +1840,7 @@ class ZoomableDirective {
|
|
|
1837
1840
|
this.zoomable = false;
|
|
1838
1841
|
this.alive = true;
|
|
1839
1842
|
this.currentTransform = zoomIdentity;
|
|
1843
|
+
this.wheelIdle = true;
|
|
1840
1844
|
this.zoomed = (event) => {
|
|
1841
1845
|
if (event.sourceEvent) {
|
|
1842
1846
|
if (Object.keys(event.sourceEvent).length !== 0) {
|
|
@@ -1844,14 +1848,14 @@ class ZoomableDirective {
|
|
|
1844
1848
|
return;
|
|
1845
1849
|
}
|
|
1846
1850
|
const origin = this.brushScale.copy().domain(this.zoomAxis.extremes);
|
|
1847
|
-
let domain = this.config.zoom?.type === ZoomType.y
|
|
1848
|
-
event.transform.rescaleY(origin).domain()
|
|
1849
|
-
event.transform.rescaleX(origin).domain();
|
|
1851
|
+
let domain = this.config.zoom?.type === ZoomType.y
|
|
1852
|
+
? event.transform.rescaleY(origin).domain()
|
|
1853
|
+
: event.transform.rescaleX(origin).domain();
|
|
1850
1854
|
const message = new ZoomMessage({
|
|
1851
1855
|
event,
|
|
1852
1856
|
axis: this.zoomAxis,
|
|
1853
1857
|
brushDomain: domain,
|
|
1854
|
-
chartId: this.config.id
|
|
1858
|
+
chartId: this.config.id,
|
|
1855
1859
|
});
|
|
1856
1860
|
this.broadcastService.broadcastZoom({
|
|
1857
1861
|
channel: this.config?.zoom?.syncChannel,
|
|
@@ -1860,7 +1864,7 @@ class ZoomableDirective {
|
|
|
1860
1864
|
}
|
|
1861
1865
|
this.zoomService.setZoom({
|
|
1862
1866
|
event,
|
|
1863
|
-
target: this.zoomAxis
|
|
1867
|
+
target: this.zoomAxis,
|
|
1864
1868
|
});
|
|
1865
1869
|
this.currentTransform = event.transform;
|
|
1866
1870
|
}
|
|
@@ -1872,119 +1876,164 @@ class ZoomableDirective {
|
|
|
1872
1876
|
}
|
|
1873
1877
|
}
|
|
1874
1878
|
ngAfterViewInit() {
|
|
1875
|
-
const enable = this.axis?.options?.zoom && this.axis?.options.visible !== false ||
|
|
1879
|
+
const enable = (this.axis?.options?.zoom && this.axis?.options.visible !== false) ||
|
|
1880
|
+
this.config?.zoom?.enable;
|
|
1876
1881
|
if (!enable) {
|
|
1877
1882
|
return;
|
|
1878
1883
|
}
|
|
1879
1884
|
this._element = d3.select(this.elementRef.nativeElement);
|
|
1880
|
-
this.zoom = d3
|
|
1881
|
-
.zoom()
|
|
1882
|
-
.extent([
|
|
1885
|
+
this.zoom = d3.zoom().extent([
|
|
1883
1886
|
[0, 0],
|
|
1884
1887
|
[this.size.width, this.size.height],
|
|
1885
1888
|
]);
|
|
1886
1889
|
if (this.config.zoom?.limitTranslateByData) {
|
|
1887
|
-
this.zoom.translateExtent([
|
|
1890
|
+
this.zoom.translateExtent([
|
|
1891
|
+
[0, 0],
|
|
1892
|
+
[this.size.width, this.size.height],
|
|
1893
|
+
]);
|
|
1888
1894
|
}
|
|
1889
|
-
const commonZoomAxis = Axis.createAxis(this.config?.zoom.type === ZoomType.x
|
|
1895
|
+
const commonZoomAxis = Axis.createAxis(this.config?.zoom.type === ZoomType.x
|
|
1896
|
+
? AxisOrientation.x
|
|
1897
|
+
: AxisOrientation.y, this.config, 0, true);
|
|
1890
1898
|
this.zoomAxis = this.axis ?? commonZoomAxis;
|
|
1891
1899
|
if (enable) {
|
|
1892
|
-
const maxZoom = this.config.zoom?.max
|
|
1893
|
-
|
|
1900
|
+
const maxZoom = this.config.zoom?.max
|
|
1901
|
+
? (this.zoomAxis.extremes[1] - this.zoomAxis.extremes[0]) /
|
|
1902
|
+
this.config.zoom?.max
|
|
1903
|
+
: this.config.zoom?.limitZoomByData
|
|
1904
|
+
? 1
|
|
1905
|
+
: 0;
|
|
1906
|
+
const minZoom = this.config.zoom?.min
|
|
1907
|
+
? (this.zoomAxis.extremes[1] - this.zoomAxis.extremes[0]) /
|
|
1908
|
+
this.config.zoom?.min
|
|
1909
|
+
: Infinity;
|
|
1894
1910
|
this.zoom.scaleExtent([maxZoom, minZoom]);
|
|
1895
1911
|
this.zoom.on('start zoom end', this.zoomed);
|
|
1896
1912
|
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
1897
1913
|
if (this.config?.zoom?.zoomBehavior === ZoomBehaviorType.wheel) {
|
|
1898
|
-
let wheeling;
|
|
1899
1914
|
let type = 'start';
|
|
1900
|
-
|
|
1915
|
+
let wheeling;
|
|
1901
1916
|
this.zoom
|
|
1902
|
-
.filter((event) => event.ctrlKey && event.type === 'wheel')
|
|
1917
|
+
.filter((event) => (event.ctrlKey && event.type === 'wheel') ||
|
|
1918
|
+
Boolean(window.TouchEvent))
|
|
1903
1919
|
.wheelDelta((event) => {
|
|
1904
|
-
const delta = this.config?.zoom.type === ZoomType.x
|
|
1920
|
+
const delta = this.config?.zoom.type === ZoomType.x
|
|
1921
|
+
? -event.deltaX
|
|
1922
|
+
: -event.deltaY;
|
|
1905
1923
|
return delta * 0.002;
|
|
1906
1924
|
});
|
|
1925
|
+
const emit = (type, event) => {
|
|
1926
|
+
const origin = this.brushScale.copy().domain(this.zoomAxis.extremes);
|
|
1927
|
+
let transform = zoomIdentity;
|
|
1928
|
+
const delta = type === 'end'
|
|
1929
|
+
? 0
|
|
1930
|
+
: this.config.zoom?.type === ZoomType.y
|
|
1931
|
+
? event.deltaY
|
|
1932
|
+
: event.deltaX;
|
|
1933
|
+
if (this.config.zoom?.type === ZoomType.y) {
|
|
1934
|
+
transform = transform.translate(0, this.currentTransform.y - delta / 2);
|
|
1935
|
+
}
|
|
1936
|
+
if (this.config.zoom?.type === ZoomType.x) {
|
|
1937
|
+
transform = transform.translate(this.currentTransform.x - delta / 2, 0);
|
|
1938
|
+
}
|
|
1939
|
+
transform = transform.scale(this.currentTransform.k);
|
|
1940
|
+
let domain = this.config.zoom?.type === ZoomType.y
|
|
1941
|
+
? transform.rescaleY(origin).domain()
|
|
1942
|
+
: transform.rescaleX(origin).domain();
|
|
1943
|
+
const message = new ZoomMessage({
|
|
1944
|
+
event: {
|
|
1945
|
+
sourceEvent: event,
|
|
1946
|
+
transform,
|
|
1947
|
+
type,
|
|
1948
|
+
},
|
|
1949
|
+
axis: this.zoomAxis,
|
|
1950
|
+
brushDomain: domain,
|
|
1951
|
+
chartId: this.config.id,
|
|
1952
|
+
});
|
|
1953
|
+
this.zoomService.setZoom({
|
|
1954
|
+
event: {
|
|
1955
|
+
sourceEvent: event,
|
|
1956
|
+
transform,
|
|
1957
|
+
type,
|
|
1958
|
+
},
|
|
1959
|
+
target: this.zoomAxis,
|
|
1960
|
+
});
|
|
1961
|
+
this._element.call(this.zoom.transform, transform);
|
|
1962
|
+
this.currentTransform = transform;
|
|
1963
|
+
this.broadcastService.broadcastZoom({
|
|
1964
|
+
channel: this.config?.zoom?.syncChannel,
|
|
1965
|
+
message,
|
|
1966
|
+
});
|
|
1967
|
+
};
|
|
1907
1968
|
this._element.on('wheel', (event) => {
|
|
1908
1969
|
event.preventDefault();
|
|
1909
1970
|
if (event.ctrlKey) {
|
|
1910
1971
|
return;
|
|
1911
1972
|
}
|
|
1912
|
-
const emit = (type) => {
|
|
1913
|
-
let transform = zoomIdentity;
|
|
1914
|
-
const delta = type === 'end' ? 0 : this.config.zoom?.type === ZoomType.y ? event.deltaY : event.deltaX;
|
|
1915
|
-
if (this.config.zoom?.type === ZoomType.y) {
|
|
1916
|
-
transform = transform.translate(0, this.currentTransform.y - delta / 2);
|
|
1917
|
-
}
|
|
1918
|
-
if (this.config.zoom?.type === ZoomType.x) {
|
|
1919
|
-
transform = transform.translate(this.currentTransform.x - delta / 2, 0);
|
|
1920
|
-
}
|
|
1921
|
-
transform = transform.scale(this.currentTransform.k);
|
|
1922
|
-
let domain = this.config.zoom?.type === ZoomType.y ?
|
|
1923
|
-
transform.rescaleY(origin).domain() :
|
|
1924
|
-
transform.rescaleX(origin).domain();
|
|
1925
|
-
const message = new ZoomMessage({
|
|
1926
|
-
event: {
|
|
1927
|
-
sourceEvent: event,
|
|
1928
|
-
transform,
|
|
1929
|
-
type
|
|
1930
|
-
},
|
|
1931
|
-
axis: this.zoomAxis,
|
|
1932
|
-
brushDomain: domain,
|
|
1933
|
-
chartId: this.config.id
|
|
1934
|
-
});
|
|
1935
|
-
this.zoomService.setZoom({
|
|
1936
|
-
event: {
|
|
1937
|
-
sourceEvent: event,
|
|
1938
|
-
transform,
|
|
1939
|
-
type
|
|
1940
|
-
},
|
|
1941
|
-
target: this.zoomAxis
|
|
1942
|
-
});
|
|
1943
|
-
this.broadcastService.broadcastZoom({
|
|
1944
|
-
channel: this.config?.zoom?.syncChannel,
|
|
1945
|
-
message,
|
|
1946
|
-
});
|
|
1947
|
-
this._element.call(this.zoom.transform, transform);
|
|
1948
|
-
this.currentTransform = transform;
|
|
1949
|
-
};
|
|
1950
1973
|
this.zone.runOutsideAngular(() => {
|
|
1951
1974
|
clearTimeout(wheeling);
|
|
1952
|
-
emit(type);
|
|
1975
|
+
emit(type, event);
|
|
1953
1976
|
type = 'zoom';
|
|
1977
|
+
this.wheelIdle = false;
|
|
1954
1978
|
wheeling = setTimeout(() => {
|
|
1955
1979
|
type = 'end';
|
|
1956
|
-
emit(type);
|
|
1980
|
+
emit(type, event);
|
|
1981
|
+
this.wheelIdle = true;
|
|
1957
1982
|
type = 'start';
|
|
1958
|
-
},
|
|
1983
|
+
}, 150);
|
|
1959
1984
|
});
|
|
1960
1985
|
});
|
|
1961
1986
|
}
|
|
1962
1987
|
}
|
|
1963
1988
|
// Subscribe to zoom events
|
|
1964
|
-
this.broadcastService
|
|
1965
|
-
|
|
1989
|
+
this.broadcastService
|
|
1990
|
+
.subscribeToZoom(this.config?.zoom.syncChannel)
|
|
1991
|
+
.pipe(takeWhile((_) => this.alive), filter((m) => m.message.event.sourceEvent instanceof MouseEvent ||
|
|
1992
|
+
m.message.event.sourceEvent instanceof WheelEvent ||
|
|
1993
|
+
(window.TouchEvent &&
|
|
1994
|
+
m.message.event.sourceEvent instanceof TouchEvent)), filter((m) => {
|
|
1995
|
+
return (this.zoomAxis.index === m.message?.axis?.index &&
|
|
1996
|
+
this.zoomAxis.orientation === m.message?.axis?.orientation);
|
|
1966
1997
|
}), tap$1((m) => {
|
|
1967
1998
|
if (this.config.id !== m.message.chartId) {
|
|
1999
|
+
this.wheelIdle = false;
|
|
2000
|
+
if (m.message.event.type === 'end') {
|
|
2001
|
+
this.wheelIdle = true;
|
|
2002
|
+
}
|
|
1968
2003
|
this._element.call(this.zoom.transform, m.message.event.transform, null, {});
|
|
1969
2004
|
}
|
|
1970
2005
|
else {
|
|
1971
|
-
if (m.message.axis.isFake && !this.zoomAxis.isFake ||
|
|
2006
|
+
if ((m.message.axis.isFake && !this.zoomAxis.isFake) ||
|
|
2007
|
+
(!m.message.axis.isFake && this.zoomAxis.isFake)) {
|
|
1972
2008
|
this._element.call(this.zoom.transform, m.message.event.transform);
|
|
1973
2009
|
}
|
|
1974
2010
|
}
|
|
1975
|
-
}))
|
|
2011
|
+
}))
|
|
2012
|
+
.subscribe();
|
|
1976
2013
|
// Subscribe to brush events x or y
|
|
1977
|
-
if ((this.config.brush?.type === BrushType.x &&
|
|
1978
|
-
|
|
1979
|
-
|
|
2014
|
+
if ((this.config.brush?.type === BrushType.x &&
|
|
2015
|
+
this.zoomAxis.orientation === AxisOrientation.x) ||
|
|
2016
|
+
(this.config.brush?.type === BrushType.y &&
|
|
2017
|
+
this.zoomAxis.orientation === AxisOrientation.y)) {
|
|
2018
|
+
combineLatest([
|
|
2019
|
+
this.broadcastService.subscribeToBrush(this.config?.zoom.syncChannel),
|
|
2020
|
+
this.chartService.size,
|
|
2021
|
+
])
|
|
2022
|
+
.pipe(takeWhile((_) => this.alive), debounceTime(150), filter((data) => Boolean(data[0].message.selection)), tap$1((data) => {
|
|
1980
2023
|
const [m] = data;
|
|
2024
|
+
if (!this.wheelIdle) {
|
|
2025
|
+
return;
|
|
2026
|
+
}
|
|
1981
2027
|
const currentTransform = d3.zoomTransform(this._element.node());
|
|
1982
|
-
if (!m.message.event &&
|
|
2028
|
+
if (!m.message.event &&
|
|
2029
|
+
this.currentSelection &&
|
|
2030
|
+
currentTransform.k !== 1) {
|
|
1983
2031
|
return;
|
|
1984
2032
|
}
|
|
1985
|
-
this.currentSelection = m.message.selection;
|
|
1986
2033
|
this.updateZoom(m);
|
|
1987
|
-
|
|
2034
|
+
this.currentSelection = m.message.selection;
|
|
2035
|
+
}))
|
|
2036
|
+
.subscribe();
|
|
1988
2037
|
}
|
|
1989
2038
|
}
|
|
1990
2039
|
ngOnDestroy() {
|
|
@@ -2040,7 +2089,9 @@ class BrushableDirective {
|
|
|
2040
2089
|
if (changes.hasOwnProperty('config')) {
|
|
2041
2090
|
this.brushService.clearPreviousSelection();
|
|
2042
2091
|
}
|
|
2043
|
-
|
|
2092
|
+
if (this.config.brush.enable) {
|
|
2093
|
+
this.brushService.applyBrush(this.element, this.config, this.brushScale);
|
|
2094
|
+
}
|
|
2044
2095
|
}
|
|
2045
2096
|
}
|
|
2046
2097
|
BrushableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.1", ngImport: i0, type: BrushableDirective, deps: [{ token: BrushService }, { token: ChartService }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -2245,10 +2296,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.1", ngImpor
|
|
|
2245
2296
|
}] } });
|
|
2246
2297
|
|
|
2247
2298
|
class ChartComponent {
|
|
2248
|
-
constructor(chartService,
|
|
2299
|
+
constructor(chartService, zoomService, scaleService) {
|
|
2249
2300
|
this.chartService = chartService;
|
|
2250
|
-
this.
|
|
2251
|
-
this.
|
|
2301
|
+
this.zoomService = zoomService;
|
|
2302
|
+
this.scaleService = scaleService;
|
|
2252
2303
|
this.pointerMove = new EventEmitter();
|
|
2253
2304
|
this.plotBandsMove = new EventEmitter();
|
|
2254
2305
|
this.plotBandClick = new EventEmitter();
|
|
@@ -2271,7 +2322,7 @@ class ChartComponent {
|
|
|
2271
2322
|
}
|
|
2272
2323
|
ngOnInit() {
|
|
2273
2324
|
this.chartService.pointerMove
|
|
2274
|
-
.pipe(takeWhile(() => this._alive), withLatestFrom(this.
|
|
2325
|
+
.pipe(takeWhile(() => this._alive), withLatestFrom(this.scaleService.xScaleMap, this.scaleService.yScaleMap, this.chartService.config))
|
|
2275
2326
|
.subscribe((data) => {
|
|
2276
2327
|
const [event, x, y, config] = data;
|
|
2277
2328
|
const tooltipTracking = config?.tooltip?.tracking;
|
|
@@ -2345,7 +2396,7 @@ class ChartComponent {
|
|
|
2345
2396
|
}
|
|
2346
2397
|
ngOnDestroy() {
|
|
2347
2398
|
this._alive = false;
|
|
2348
|
-
this.
|
|
2399
|
+
this.zoomService.broadcastSubscription?.forEach((sub) => {
|
|
2349
2400
|
sub.unsubscribe();
|
|
2350
2401
|
});
|
|
2351
2402
|
}
|