@tetacom/svg-charts 1.3.3 → 1.4.1
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/directives/zoomable.directive.d.ts +1 -3
- package/chart/service/zoom.service.d.ts +4 -1
- package/esm2020/chart/chart-container/plotband/plot-band.component.mjs +4 -2
- package/esm2020/chart/directives/brushable.directive.mjs +2 -2
- package/esm2020/chart/directives/zoomable.directive.mjs +58 -63
- package/esm2020/chart/service/brush.service.mjs +1 -3
- package/esm2020/chart/service/zoom.service.mjs +17 -2
- package/fesm2015/tetacom-svg-charts.mjs +88 -75
- package/fesm2015/tetacom-svg-charts.mjs.map +1 -1
- package/fesm2020/tetacom-svg-charts.mjs +76 -65
- package/fesm2020/tetacom-svg-charts.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BehaviorSubject, shareReplay, } from 'rxjs';
|
|
1
|
+
import { combineLatest, BehaviorSubject, shareReplay, filter, } from 'rxjs';
|
|
2
2
|
import { AxisOrientation } from '../model/enum/axis-orientation';
|
|
3
3
|
import { Injectable } from '@angular/core';
|
|
4
4
|
import { zoomIdentity } from 'd3';
|
|
@@ -27,7 +27,19 @@ export class ZoomService {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
setBroadcastChannel(channel) {
|
|
30
|
+
if (this.broadcastSub) {
|
|
31
|
+
this.broadcastSub?.unsubscribe();
|
|
32
|
+
}
|
|
30
33
|
this.broadcastChannel = channel;
|
|
34
|
+
if (this.broadcastChannel?.length) {
|
|
35
|
+
this.broadcastSub = combineLatest([this._broadcast.subscribeToZoom(this.broadcastChannel), this._chart.config])
|
|
36
|
+
.pipe(filter(([zoom, config]) => {
|
|
37
|
+
return zoom.message?.chartId !== config.id;
|
|
38
|
+
}))
|
|
39
|
+
.subscribe(([zoom, config]) => {
|
|
40
|
+
this.fireZoom(zoom.message);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
|
|
33
45
|
const zoomScale = Math.abs(scale(originalDomain[1]) - scale(originalDomain[0])) / Math.abs(scale(targetDomain[1]) - scale(targetDomain[0]));
|
|
@@ -50,6 +62,9 @@ export class ZoomService {
|
|
|
50
62
|
}
|
|
51
63
|
return transform;
|
|
52
64
|
}
|
|
65
|
+
ngOnDestroy() {
|
|
66
|
+
this.broadcastSub?.unsubscribe();
|
|
67
|
+
}
|
|
53
68
|
}
|
|
54
69
|
ZoomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, deps: [{ token: i1.BroadcastService }, { token: i2.ChartService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
55
70
|
ZoomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, providedIn: 'root' });
|
|
@@ -59,4 +74,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImpor
|
|
|
59
74
|
providedIn: 'root',
|
|
60
75
|
}]
|
|
61
76
|
}], ctorParameters: function () { return [{ type: i1.BroadcastService }, { type: i2.ChartService }]; } });
|
|
62
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiem9vbS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NoYXJ0L3NlcnZpY2Uvem9vbS5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBQyxhQUFhLEVBQUUsZUFBZSxFQUFjLFdBQVcsRUFBZ0IsTUFBTSxHQUFFLE1BQU0sTUFBTSxDQUFDO0FBQ3BHLE9BQU8sRUFBQyxlQUFlLEVBQ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AucGlwZShmaWx0ZXIoKFt6b29tLCBjb25maWddKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIHpvb20ubWVzc2FnZT8uY2hhcnRJZCAhPT0gY29uZmlnLmlkO1xuICAgICAgICB9KSlcbiAgICAgICAgLnN1YnNjcmliZSgoW3pvb20sIGNvbmZpZ10pID0+IHtcbiAgICAgICAgICB0aGlzLmZpcmVab29tKHpvb20ubWVzc2FnZSk7XG4gICAgICAgIH0pO1xuICAgIH1cbiAgfVxuXG4gIGdldEQzVHJhbnNmb3JtKHRhcmdldERvbWFpbjogW251bWJlciwgbnVtYmVyXSxcbiAgICAgICAgICAgICAgICAgb3JpZ2luYWxEb21haW46IFtudW1iZXIsIG51bWJlcl0sXG4gICAgICAgICAgICAgICAgIHNjYWxlLFxuICAgICAgICAgICAgICAgICBvcmllbnRhdGlvbjogQXhpc09yaWVudGF0aW9uLFxuICAgICAgICAgICAgICAgICBpbnZlcnRlZDogYm9vbGVhbikge1xuICAgIGNvbnN0IHpvb21TY2FsZSA9IE1hdGguYWJzKHNjYWxlKG9yaWdpbmFsRG9tYWluWzFdKSAtIHNjYWxlKG9yaWdpbmFsRG9tYWluWzBdKSkgLyBNYXRoLmFicyhzY2FsZSh0YXJnZXREb21haW5bMV0pIC0gc2NhbGUodGFyZ2V0RG9tYWluWzBdKSk7XG4gICAgbGV0IHRyYW5zZm9ybSA9IHpvb21JZGVudGl0eS5zY2FsZSh6b29tU2NhbGUpO1xuICAgIGlmIChvcmllbnRhdGlvbiA9PT0gQXhpc09yaWVudGF0aW9uLngpIHtcbiAgICAgIGlmICghIWludmVydGVkKSB7XG4gICAgICAgIHRyYW5zZm9ybSA9IHRyYW5zZm9ybS50cmFuc2xhdGUoLXNjYWxlKE1hdGgubWF4KC4uLnRhcmdldERvbWFpbikpLCAwKTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRyYW5zZm9ybSA9IHRyYW5zZm9ybS50cmFuc2xhdGUoLXNjYWxlKE1hdGgubWluKC4uLnRhcmdldERvbWFpbikpLCAwKTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICBpZiAob3JpZW50YXRpb24gPT09IEF4aXNPcmllbnRhdGlvbi55KSB7XG4gICAgICBpZiAoISFpbnZlcnRlZCkge1xuICAgICAgICB0cmFuc2Zvcm0gPSB0cmFuc2Zvcm0udHJhbnNsYXRlKDAsIC1zY2FsZShNYXRoLm1pbiguLi50YXJnZXREb21haW4pKSk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0cmFuc2Zvcm0gPSB0cmFuc2Zvcm0udHJhbnNsYXRlKDAsIC1zY2FsZShNYXRoLm1heCguLi50YXJnZXREb21haW4pKSk7XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiB0cmFuc2Zvcm07XG4gIH1cblxuICBuZ09uRGVzdHJveSgpIHtcbiAgICB0aGlzLmJyb2FkY2FzdFN1Yj8udW5zdWJzY3JpYmUoKTtcbiAgfVxufVxuIl19
|
|
@@ -404,7 +404,21 @@ class ZoomService {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
setBroadcastChannel(channel) {
|
|
407
|
+
var _a, _b;
|
|
408
|
+
if (this.broadcastSub) {
|
|
409
|
+
(_a = this.broadcastSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
410
|
+
}
|
|
407
411
|
this.broadcastChannel = channel;
|
|
412
|
+
if ((_b = this.broadcastChannel) === null || _b === void 0 ? void 0 : _b.length) {
|
|
413
|
+
this.broadcastSub = combineLatest([this._broadcast.subscribeToZoom(this.broadcastChannel), this._chart.config])
|
|
414
|
+
.pipe(filter(([zoom, config]) => {
|
|
415
|
+
var _a;
|
|
416
|
+
return ((_a = zoom.message) === null || _a === void 0 ? void 0 : _a.chartId) !== config.id;
|
|
417
|
+
}))
|
|
418
|
+
.subscribe(([zoom, config]) => {
|
|
419
|
+
this.fireZoom(zoom.message);
|
|
420
|
+
});
|
|
421
|
+
}
|
|
408
422
|
}
|
|
409
423
|
getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
|
|
410
424
|
const zoomScale = Math.abs(scale(originalDomain[1]) - scale(originalDomain[0])) / Math.abs(scale(targetDomain[1]) - scale(targetDomain[0]));
|
|
@@ -427,6 +441,10 @@ class ZoomService {
|
|
|
427
441
|
}
|
|
428
442
|
return transform;
|
|
429
443
|
}
|
|
444
|
+
ngOnDestroy() {
|
|
445
|
+
var _a;
|
|
446
|
+
(_a = this.broadcastSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
447
|
+
}
|
|
430
448
|
}
|
|
431
449
|
ZoomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, deps: [{ token: BroadcastService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
432
450
|
ZoomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomService, providedIn: 'root' });
|
|
@@ -769,9 +787,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImpor
|
|
|
769
787
|
}], ctorParameters: function () { return [{ type: ChartService }, { type: ZoomService }]; } });
|
|
770
788
|
|
|
771
789
|
class BrushService {
|
|
772
|
-
// private _outBrushDomain = new ReplaySubject<[number, number]>(1);
|
|
773
790
|
constructor() {
|
|
774
|
-
// outBrushDomain: Observable<[number, number]>;
|
|
775
791
|
this._brushDomain = new ReplaySubject(1);
|
|
776
792
|
this.brushDomain = this._brushDomain.asObservable();
|
|
777
793
|
}
|
|
@@ -1735,7 +1751,9 @@ class PlotBandComponent {
|
|
|
1735
1751
|
let [min, max] = this.scale.domain();
|
|
1736
1752
|
min = min instanceof Date ? min.getTime() : min;
|
|
1737
1753
|
max = max instanceof Date ? max.getTime() : max;
|
|
1738
|
-
const
|
|
1754
|
+
const from = this.plotBand.from instanceof Date ? this.plotBand.from.getTime() : this.plotBand.from;
|
|
1755
|
+
const to = this.plotBand.to instanceof Date ? this.plotBand.to.getTime() : this.plotBand.to;
|
|
1756
|
+
const position = ((from <= min ? min : from) + (to >= max ? max : to)) / 2;
|
|
1739
1757
|
return this.scale(position);
|
|
1740
1758
|
};
|
|
1741
1759
|
}
|
|
@@ -1984,41 +2002,37 @@ class BrushMessage {
|
|
|
1984
2002
|
}
|
|
1985
2003
|
|
|
1986
2004
|
class ZoomableDirective {
|
|
1987
|
-
constructor(elementRef, zoomService, chartService,
|
|
2005
|
+
constructor(elementRef, zoomService, chartService, zone) {
|
|
1988
2006
|
this.elementRef = elementRef;
|
|
1989
2007
|
this.zoomService = zoomService;
|
|
1990
2008
|
this.chartService = chartService;
|
|
1991
|
-
this.broadcast = broadcast;
|
|
1992
2009
|
this.zone = zone;
|
|
1993
2010
|
this.zoomable = false;
|
|
1994
2011
|
this.crosshair = false;
|
|
1995
2012
|
this.alive = true;
|
|
1996
2013
|
this.currentTransform = zoomIdentity;
|
|
1997
2014
|
this.zoomed = (event) => {
|
|
1998
|
-
if (
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
this.zoomService.fireZoom(message);
|
|
2019
|
-
this.zoomService.broadcastZoom(message);
|
|
2015
|
+
if (event.sourceEvent) {
|
|
2016
|
+
if (Object.keys(event.sourceEvent).length !== 0) {
|
|
2017
|
+
const origin = this.axis.scale.copy().domain(this.axis.originDomain);
|
|
2018
|
+
let domain = this.axis.orientation === AxisOrientation.y
|
|
2019
|
+
? event.transform.rescaleY(origin).domain()
|
|
2020
|
+
: event.transform.rescaleX(origin).domain();
|
|
2021
|
+
const message = new ZoomMessage({
|
|
2022
|
+
eventType: event.type,
|
|
2023
|
+
axis: {
|
|
2024
|
+
index: this.axis.index,
|
|
2025
|
+
orientation: this.axis.orientation,
|
|
2026
|
+
},
|
|
2027
|
+
element: this.elementRef,
|
|
2028
|
+
domain: domain,
|
|
2029
|
+
chartId: this.config.id
|
|
2030
|
+
});
|
|
2031
|
+
this.zoomService.fireZoom(message);
|
|
2032
|
+
this.zoomService.broadcastZoom(message);
|
|
2033
|
+
}
|
|
2034
|
+
this.currentTransform = event.transform;
|
|
2020
2035
|
}
|
|
2021
|
-
this.currentTransform = event.transform;
|
|
2022
2036
|
};
|
|
2023
2037
|
}
|
|
2024
2038
|
ngOnInit() {
|
|
@@ -2040,10 +2054,10 @@ class ZoomableDirective {
|
|
|
2040
2054
|
}
|
|
2041
2055
|
initZoomSync() {
|
|
2042
2056
|
this.zoomService.zoomed.pipe(takeWhile(() => this.alive)).subscribe((zoomed) => {
|
|
2043
|
-
var _a, _b
|
|
2057
|
+
var _a, _b;
|
|
2044
2058
|
if (this._element && this.elementRef !== (zoomed === null || zoomed === void 0 ? void 0 : zoomed.element)
|
|
2045
2059
|
&& ((_a = zoomed === null || zoomed === void 0 ? void 0 : zoomed.axis) === null || _a === void 0 ? void 0 : _a.index) === this.axis.index
|
|
2046
|
-
&& ((_b = zoomed === null || zoomed === void 0 ? void 0 : zoomed.axis) === null || _b === void 0 ? void 0 : _b.orientation) === this.axis.orientation
|
|
2060
|
+
&& ((_b = zoomed === null || zoomed === void 0 ? void 0 : zoomed.axis) === null || _b === void 0 ? void 0 : _b.orientation) === this.axis.orientation) {
|
|
2047
2061
|
const scale = this.axis.scale.copy().domain(this.axis.originDomain);
|
|
2048
2062
|
let transform;
|
|
2049
2063
|
if (zoomed.domain === null) {
|
|
@@ -2053,18 +2067,13 @@ class ZoomableDirective {
|
|
|
2053
2067
|
transform =
|
|
2054
2068
|
this.zoomService.getD3Transform(zoomed.domain, this.axis.originDomain, scale, this.axis.orientation, this.axis.options.inverted);
|
|
2055
2069
|
}
|
|
2056
|
-
|
|
2057
|
-
this._element.transition().call(this.zoom.transform, transform);
|
|
2058
|
-
}
|
|
2059
|
-
else {
|
|
2060
|
-
this._element.call(this.zoom.transform, transform);
|
|
2061
|
-
}
|
|
2070
|
+
this._element.call(this.zoom.transform, transform);
|
|
2062
2071
|
this.currentTransform = transform;
|
|
2063
2072
|
}
|
|
2064
2073
|
});
|
|
2065
2074
|
}
|
|
2066
2075
|
initZoomListeners() {
|
|
2067
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
2076
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2068
2077
|
const enable = (((_b = (_a = this.axis) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.zoom) && ((_c = this.axis) === null || _c === void 0 ? void 0 : _c.options.visible) !== false) ||
|
|
2069
2078
|
((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.zoom) === null || _e === void 0 ? void 0 : _e.enable);
|
|
2070
2079
|
if (!enable) {
|
|
@@ -2077,53 +2086,41 @@ class ZoomableDirective {
|
|
|
2077
2086
|
]);
|
|
2078
2087
|
const min = ((_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.zoom) === null || _g === void 0 ? void 0 : _g.minTranslate)
|
|
2079
2088
|
? this.axis.scale((_j = (_h = this.config) === null || _h === void 0 ? void 0 : _h.zoom) === null || _j === void 0 ? void 0 : _j.minTranslate)
|
|
2080
|
-
:
|
|
2081
|
-
const max = ((_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.zoom) === null || _l === void 0 ? void 0 : _l.maxTranslate)
|
|
2082
|
-
? this.axis.scale((_o = (_m = this.config) === null || _m === void 0 ? void 0 : _m.zoom) === null || _o === void 0 ? void 0 : _o.maxTranslate)
|
|
2083
|
-
:
|
|
2084
|
-
if (this.axis.orientation === AxisOrientation.x &&
|
|
2089
|
+
: -Infinity;
|
|
2090
|
+
const max = (((_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.zoom) === null || _l === void 0 ? void 0 : _l.maxTranslate)
|
|
2091
|
+
? this.axis.scale((_o = (_m = this.config) === null || _m === void 0 ? void 0 : _m.zoom) === null || _o === void 0 ? void 0 : _o.maxTranslate) - (this.axis.orientation === AxisOrientation.x ? this.size.width : this.size.height)
|
|
2092
|
+
: Infinity);
|
|
2093
|
+
if (this.axis.orientation === AxisOrientation.x && this.config.zoom.type === ZoomType.x) {
|
|
2085
2094
|
this.zoom.translateExtent([
|
|
2086
|
-
[min,
|
|
2087
|
-
[max,
|
|
2095
|
+
[min, -Infinity],
|
|
2096
|
+
[max, Infinity],
|
|
2088
2097
|
]);
|
|
2089
2098
|
}
|
|
2090
|
-
if (this.axis.orientation === AxisOrientation.y &&
|
|
2099
|
+
if (this.axis.orientation === AxisOrientation.y && this.config.zoom.type === ZoomType.y) {
|
|
2091
2100
|
this.zoom.translateExtent([
|
|
2092
|
-
[
|
|
2093
|
-
[
|
|
2101
|
+
[-Infinity, min],
|
|
2102
|
+
[Infinity, max],
|
|
2094
2103
|
]);
|
|
2095
2104
|
}
|
|
2096
|
-
if ((
|
|
2097
|
-
this.zoom.wheelDelta((
|
|
2098
|
-
}
|
|
2099
|
-
const maxZoom = ((_t = this.config.zoom) === null || _t === void 0 ? void 0 : _t.max)
|
|
2100
|
-
? (this.axis.extremes[1] - this.axis.extremes[0]) / ((_u = this.config.zoom) === null || _u === void 0 ? void 0 : _u.max) : ((_v = this.config.zoom) === null || _v === void 0 ? void 0 : _v.limitZoomByData) ? 1 : 0;
|
|
2101
|
-
if ((_w = this.config.zoom) === null || _w === void 0 ? void 0 : _w.wheelDelta) {
|
|
2102
|
-
this.zoom.wheelDelta((_x = this.config.zoom) === null || _x === void 0 ? void 0 : _x.wheelDelta);
|
|
2105
|
+
if ((_p = this.config.zoom) === null || _p === void 0 ? void 0 : _p.wheelDelta) {
|
|
2106
|
+
this.zoom.wheelDelta((_q = this.config.zoom) === null || _q === void 0 ? void 0 : _q.wheelDelta);
|
|
2103
2107
|
}
|
|
2104
|
-
const
|
|
2108
|
+
const maxZoom = ((_r = this.config.zoom) === null || _r === void 0 ? void 0 : _r.max)
|
|
2105
2109
|
? (this.axis.extremes[1] - this.axis.extremes[0]) /
|
|
2106
|
-
((
|
|
2110
|
+
((_s = this.config.zoom) === null || _s === void 0 ? void 0 : _s.max)
|
|
2111
|
+
: ((_t = this.config.zoom) === null || _t === void 0 ? void 0 : _t.limitZoomByData)
|
|
2112
|
+
? 1
|
|
2113
|
+
: 0;
|
|
2114
|
+
const minZoom = ((_u = this.config.zoom) === null || _u === void 0 ? void 0 : _u.min)
|
|
2115
|
+
? (this.axis.extremes[1] - this.axis.extremes[0]) /
|
|
2116
|
+
((_v = this.config.zoom) === null || _v === void 0 ? void 0 : _v.min)
|
|
2107
2117
|
: Infinity;
|
|
2108
2118
|
this.zoom.scaleExtent([maxZoom, minZoom]);
|
|
2109
2119
|
this.zoom.on('zoom end', this.zoomed);
|
|
2110
2120
|
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2111
|
-
if (((
|
|
2121
|
+
if (((_x = (_w = this.config) === null || _w === void 0 ? void 0 : _w.zoom) === null || _x === void 0 ? void 0 : _x.zoomBehavior) === ZoomBehaviorType.wheel) {
|
|
2112
2122
|
this.runWheelTranslate();
|
|
2113
2123
|
}
|
|
2114
|
-
this.broadcast.subscribeToZoom((_2 = this.config) === null || _2 === void 0 ? void 0 : _2.zoom.syncChannel).subscribe((zoom) => {
|
|
2115
|
-
var _a, _b;
|
|
2116
|
-
if (zoom.message.chartId !== ((_a = this.config) === null || _a === void 0 ? void 0 : _a.id) && zoom.message.axis.orientation === this.axis.orientation && zoom.message.axis.index === this.axis.index) {
|
|
2117
|
-
const scale = this.axis.scale.copy().domain(this.axis.originDomain);
|
|
2118
|
-
const transform = this.zoomService.getD3Transform(zoom.message.domain, this.axis.originDomain, scale, this.axis.orientation, this.axis.options.inverted);
|
|
2119
|
-
if ((_b = zoom.message.style) === null || _b === void 0 ? void 0 : _b.transition) {
|
|
2120
|
-
this._element.transition().duration(300).call(this.zoom.transform, transform, null, { type: 'broadcast' });
|
|
2121
|
-
}
|
|
2122
|
-
else {
|
|
2123
|
-
this._element.call(this.zoom.transform, transform, null, { type: 'broadcast' });
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
});
|
|
2127
2124
|
}
|
|
2128
2125
|
runWheelTranslate() {
|
|
2129
2126
|
let type = 'start';
|
|
@@ -2142,6 +2139,7 @@ class ZoomableDirective {
|
|
|
2142
2139
|
});
|
|
2143
2140
|
const emit = (type, event) => {
|
|
2144
2141
|
var _a;
|
|
2142
|
+
const origin = this.axis.scale.copy().domain(this.axis.originDomain);
|
|
2145
2143
|
let transform = zoomIdentity;
|
|
2146
2144
|
const delta = type === 'end'
|
|
2147
2145
|
? 0
|
|
@@ -2155,7 +2153,22 @@ class ZoomableDirective {
|
|
|
2155
2153
|
transform = transform.translate(this.currentTransform.x - delta / 2, 0);
|
|
2156
2154
|
}
|
|
2157
2155
|
transform = transform.scale(this.currentTransform.k);
|
|
2158
|
-
|
|
2156
|
+
let domain = this.axis.orientation === AxisOrientation.y
|
|
2157
|
+
? transform.rescaleY(origin).domain()
|
|
2158
|
+
: transform.rescaleX(origin).domain();
|
|
2159
|
+
const message = new ZoomMessage({
|
|
2160
|
+
eventType: type,
|
|
2161
|
+
element: this.elementRef,
|
|
2162
|
+
axis: {
|
|
2163
|
+
index: this.axis.index,
|
|
2164
|
+
orientation: this.axis.orientation
|
|
2165
|
+
},
|
|
2166
|
+
domain,
|
|
2167
|
+
chartId: this.config.id,
|
|
2168
|
+
});
|
|
2169
|
+
(_a = this._element) === null || _a === void 0 ? void 0 : _a.call(this.zoom.transform, transform);
|
|
2170
|
+
this.zoomService.fireZoom(message);
|
|
2171
|
+
this.zoomService.broadcastZoom(message);
|
|
2159
2172
|
this.currentTransform = transform;
|
|
2160
2173
|
};
|
|
2161
2174
|
this._element.on('wheel', (event) => {
|
|
@@ -2175,14 +2188,14 @@ class ZoomableDirective {
|
|
|
2175
2188
|
});
|
|
2176
2189
|
}
|
|
2177
2190
|
}
|
|
2178
|
-
ZoomableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomableDirective, deps: [{ token: i0.ElementRef }, { token: ZoomService }, { token: ChartService }, { token:
|
|
2191
|
+
ZoomableDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomableDirective, deps: [{ token: i0.ElementRef }, { token: ZoomService }, { token: ChartService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2179
2192
|
ZoomableDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.2", type: ZoomableDirective, selector: "[tetaZoomable]", inputs: { config: "config", axis: "axis", size: "size" }, host: { properties: { "class.zoomable": "this.zoomable", "class.crosshair": "this.crosshair" } }, ngImport: i0 });
|
|
2180
2193
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: ZoomableDirective, decorators: [{
|
|
2181
2194
|
type: Directive,
|
|
2182
2195
|
args: [{
|
|
2183
2196
|
selector: '[tetaZoomable]',
|
|
2184
2197
|
}]
|
|
2185
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ZoomService }, { type: ChartService }, { type:
|
|
2198
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: ZoomService }, { type: ChartService }, { type: i0.NgZone }]; }, propDecorators: { config: [{
|
|
2186
2199
|
type: Input
|
|
2187
2200
|
}], axis: [{
|
|
2188
2201
|
type: Input
|
|
@@ -2220,11 +2233,11 @@ class BrushableDirective {
|
|
|
2220
2233
|
this._alive = false;
|
|
2221
2234
|
}
|
|
2222
2235
|
ngAfterViewInit() {
|
|
2223
|
-
var _a, _b, _c, _d;
|
|
2236
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2224
2237
|
if ((_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.brush) === null || _b === void 0 ? void 0 : _b.enable) {
|
|
2225
2238
|
const brushMessage = new BrushMessage({
|
|
2226
2239
|
chartId: this.config.id,
|
|
2227
|
-
selection: [(_c = this.config
|
|
2240
|
+
selection: [(_d = (_c = this.config) === null || _c === void 0 ? void 0 : _c.brush) === null || _d === void 0 ? void 0 : _d.from, (_f = (_e = this.config) === null || _e === void 0 ? void 0 : _e.brush) === null || _f === void 0 ? void 0 : _f.to],
|
|
2228
2241
|
});
|
|
2229
2242
|
this.brushService.setBrush(brushMessage);
|
|
2230
2243
|
}
|