@tetacom/svg-charts 1.3.0 → 1.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/chart/chart-container/x-axis/x-axis.component.d.ts +7 -5
- package/chart/model/enum/clip-points-direction.d.ts +2 -1
- package/chart/model/i-chart-config.d.ts +2 -0
- package/esm2020/chart/chart-container/crosshair/crosshair.component.mjs +1 -3
- package/esm2020/chart/chart-container/series/linear-series-base.mjs +2 -2
- package/esm2020/chart/chart-container/x-axis/x-axis.component.mjs +12 -6
- package/esm2020/chart/directives/zoomable.directive.mjs +17 -5
- package/esm2020/chart/model/enum/clip-points-direction.mjs +2 -1
- package/esm2020/chart/model/i-chart-config.mjs +1 -1
- package/esm2020/chart/service/zoom.service.mjs +2 -2
- package/fesm2015/tetacom-svg-charts.mjs +37 -20
- package/fesm2015/tetacom-svg-charts.mjs.map +1 -1
- package/fesm2020/tetacom-svg-charts.mjs +28 -11
- package/fesm2020/tetacom-svg-charts.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -122,6 +122,7 @@ var ClipPointsDirection;
|
|
|
122
122
|
(function (ClipPointsDirection) {
|
|
123
123
|
ClipPointsDirection[ClipPointsDirection["x"] = 0] = "x";
|
|
124
124
|
ClipPointsDirection[ClipPointsDirection["y"] = 1] = "y";
|
|
125
|
+
ClipPointsDirection[ClipPointsDirection["none"] = 2] = "none";
|
|
125
126
|
})(ClipPointsDirection || (ClipPointsDirection = {}));
|
|
126
127
|
|
|
127
128
|
const defaultSeriesConfig = () => ({
|
|
@@ -420,7 +421,7 @@ class ZoomService {
|
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
|
|
423
|
-
const zoomScale = Math.abs(originalDomain[1] - originalDomain[0]) / Math.abs(targetDomain[1] - targetDomain[0]);
|
|
424
|
+
const zoomScale = Math.abs(scale(originalDomain[1]) - scale(originalDomain[0])) / Math.abs(scale(targetDomain[1]) - scale(targetDomain[0]));
|
|
424
425
|
let transform = zoomIdentity.scale(zoomScale);
|
|
425
426
|
if (orientation === AxisOrientation.x) {
|
|
426
427
|
if (!!inverted) {
|
|
@@ -863,7 +864,7 @@ class LinearSeriesBase extends SeriesBaseComponent {
|
|
|
863
864
|
set series(series) {
|
|
864
865
|
var _a;
|
|
865
866
|
this.__series = series;
|
|
866
|
-
this.markers = (_a = this.__series.data) === null || _a === void 0 ? void 0 : _a.filter((_) => (_ === null || _ === void 0 ? void 0 : _.marker) && (_ === null || _ === void 0 ? void 0 : _.x) !== undefined && (_ === null || _ === void 0 ? void 0 : _.y) !== undefined);
|
|
867
|
+
this.markers = (_a = this.__series.data) === null || _a === void 0 ? void 0 : _a.filter((_) => (_ === null || _ === void 0 ? void 0 : _.marker) && (_ === null || _ === void 0 ? void 0 : _.x) !== undefined && (_ === null || _ === void 0 ? void 0 : _.y) !== undefined && (_ === null || _ === void 0 ? void 0 : _.x) !== null && (_ === null || _ === void 0 ? void 0 : _.y) !== null);
|
|
867
868
|
}
|
|
868
869
|
get series() {
|
|
869
870
|
return this.__series;
|
|
@@ -1598,13 +1599,14 @@ class XAxisComponent {
|
|
|
1598
1599
|
constructor(scaleService, _svc) {
|
|
1599
1600
|
this.scaleService = scaleService;
|
|
1600
1601
|
this._svc = _svc;
|
|
1602
|
+
this.update$ = new BehaviorSubject(null);
|
|
1601
1603
|
this._alive = true;
|
|
1602
1604
|
this.x = this.scaleService.scales.pipe(map((_) => {
|
|
1603
1605
|
var _a;
|
|
1604
1606
|
return (_a = _.x.get(this.axis.index)) === null || _a === void 0 ? void 0 : _a.scale;
|
|
1605
1607
|
}));
|
|
1606
|
-
this.ticks = this.x.pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1607
|
-
const [x, size] = _;
|
|
1608
|
+
this.ticks = combineLatest([this.x, this.update$]).pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1609
|
+
const [[x], size] = _;
|
|
1608
1610
|
const tickSize = x.ticks().map((_) => getTextWidth(this.axis.options.tickFormat ? this.axis.options.tickFormat(_) : this.axis.defaultFormatter()(_), 0.45, 11));
|
|
1609
1611
|
return x.ticks(size.width / parseInt(d3.max(tickSize), 10) / 10);
|
|
1610
1612
|
}));
|
|
@@ -1617,9 +1619,14 @@ class XAxisComponent {
|
|
|
1617
1619
|
ngOnDestroy() {
|
|
1618
1620
|
this._alive = false;
|
|
1619
1621
|
}
|
|
1622
|
+
ngOnChanges(changes) {
|
|
1623
|
+
if (changes.hasOwnProperty('axis')) {
|
|
1624
|
+
this.update$.next();
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1620
1627
|
}
|
|
1621
1628
|
XAxisComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, deps: [{ token: ScaleService }, { token: ChartService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1622
|
-
XAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: XAxisComponent, selector: "[teta-x-axis]", inputs: { axis: "axis", size: "size" }, ngImport: i0, template: "<ng-container *ngIf=\"{x: x | async, ticks: ticks | async} as data\">\n <svg:g text-anchor=\"middle\" *ngFor=\"let tick of data.ticks\" [attr.transform]=\"'translate('+ data.x(tick) +', 0)'\">\n <text fill=\"var(--color-text-70)\" [attr.dy]=\"axis.options.opposite ? '-0.71em' : '0.71em'\" [attr.y]=\"axis.options.opposite ? 0 : 9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.y2]=\"axis.options.opposite ? -6 : 6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text fill=\"var(--color-text-70)\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1629
|
+
XAxisComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.2", type: XAxisComponent, selector: "[teta-x-axis]", inputs: { axis: "axis", size: "size" }, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"{x: x | async, ticks: ticks | async} as data\">\n <svg:g text-anchor=\"middle\" *ngFor=\"let tick of data.ticks\" [attr.transform]=\"'translate('+ data.x(tick) +', 0)'\">\n <text fill=\"var(--color-text-70)\" [attr.dy]=\"axis.options.opposite ? '-0.71em' : '0.71em'\" [attr.y]=\"axis.options.opposite ? 0 : 9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.y2]=\"axis.options.opposite ? -6 : 6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text fill=\"var(--color-text-70)\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"], dependencies: [{ kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1623
1630
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, decorators: [{
|
|
1624
1631
|
type: Component,
|
|
1625
1632
|
args: [{ selector: '[teta-x-axis]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngIf=\"{x: x | async, ticks: ticks | async} as data\">\n <svg:g text-anchor=\"middle\" *ngFor=\"let tick of data.ticks\" [attr.transform]=\"'translate('+ data.x(tick) +', 0)'\">\n <text fill=\"var(--color-text-70)\" [attr.dy]=\"axis.options.opposite ? '-0.71em' : '0.71em'\" [attr.y]=\"axis.options.opposite ? 0 : 9\">{{ this.axis.options.tickFormat ? this.axis.options.tickFormat(tick) : this.axis.defaultFormatter()(tick) }}</text>\n <line stroke=\"var(--color-text-30)\" [attr.y2]=\"axis.options.opposite ? -6 : 6\"></line>\n </svg:g>\n\n <svg:g class=\"label-axis font-caption\" [attr.transform]=\"getLabelTransform()\">\n <text fill=\"var(--color-text-70)\" text-anchor=\"middle\" dominant-baseline=\"middle\">{{ axis.options.title }}</text>\n </svg:g>\n</ng-container>\n\n", styles: [":host .tick{stroke:var(--color-text-20)}\n"] }]
|
|
@@ -2071,7 +2078,7 @@ class ZoomableDirective {
|
|
|
2071
2078
|
});
|
|
2072
2079
|
}
|
|
2073
2080
|
initZoomListeners() {
|
|
2074
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
2081
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
2075
2082
|
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) ||
|
|
2076
2083
|
((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.zoom) === null || _e === void 0 ? void 0 : _e.enable);
|
|
2077
2084
|
if (!enable) {
|
|
@@ -2082,29 +2089,41 @@ class ZoomableDirective {
|
|
|
2082
2089
|
[0, 0],
|
|
2083
2090
|
[this.size.width, this.size.height],
|
|
2084
2091
|
]);
|
|
2085
|
-
|
|
2092
|
+
const min = ((_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.zoom) === null || _g === void 0 ? void 0 : _g.minTranslate)
|
|
2093
|
+
? this.axis.scale((_j = (_h = this.config) === null || _h === void 0 ? void 0 : _h.zoom) === null || _j === void 0 ? void 0 : _j.minTranslate)
|
|
2094
|
+
: -Infinity;
|
|
2095
|
+
const max = (((_l = (_k = this.config) === null || _k === void 0 ? void 0 : _k.zoom) === null || _l === void 0 ? void 0 : _l.maxTranslate)
|
|
2096
|
+
? 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)
|
|
2097
|
+
: Infinity);
|
|
2098
|
+
if (this.axis.orientation === AxisOrientation.x && this.config.zoom.type === ZoomType.x) {
|
|
2099
|
+
this.zoom.translateExtent([
|
|
2100
|
+
[min, -Infinity],
|
|
2101
|
+
[max, Infinity],
|
|
2102
|
+
]);
|
|
2103
|
+
}
|
|
2104
|
+
if (this.axis.orientation === AxisOrientation.y && this.config.zoom.type === ZoomType.y) {
|
|
2086
2105
|
this.zoom.translateExtent([
|
|
2087
|
-
[
|
|
2088
|
-
[
|
|
2106
|
+
[-Infinity, min],
|
|
2107
|
+
[Infinity, max],
|
|
2089
2108
|
]);
|
|
2090
2109
|
}
|
|
2091
|
-
if ((
|
|
2092
|
-
this.zoom.wheelDelta((
|
|
2110
|
+
if ((_p = this.config.zoom) === null || _p === void 0 ? void 0 : _p.wheelDelta) {
|
|
2111
|
+
this.zoom.wheelDelta((_q = this.config.zoom) === null || _q === void 0 ? void 0 : _q.wheelDelta);
|
|
2093
2112
|
}
|
|
2094
|
-
const maxZoom = ((
|
|
2113
|
+
const maxZoom = ((_r = this.config.zoom) === null || _r === void 0 ? void 0 : _r.max)
|
|
2095
2114
|
? (this.axis.extremes[1] - this.axis.extremes[0]) /
|
|
2096
|
-
((
|
|
2097
|
-
: ((
|
|
2115
|
+
((_s = this.config.zoom) === null || _s === void 0 ? void 0 : _s.max)
|
|
2116
|
+
: ((_t = this.config.zoom) === null || _t === void 0 ? void 0 : _t.limitZoomByData)
|
|
2098
2117
|
? 1
|
|
2099
2118
|
: 0;
|
|
2100
|
-
const minZoom = ((
|
|
2119
|
+
const minZoom = ((_u = this.config.zoom) === null || _u === void 0 ? void 0 : _u.min)
|
|
2101
2120
|
? (this.axis.extremes[1] - this.axis.extremes[0]) /
|
|
2102
|
-
((
|
|
2121
|
+
((_v = this.config.zoom) === null || _v === void 0 ? void 0 : _v.min)
|
|
2103
2122
|
: Infinity;
|
|
2104
2123
|
this.zoom.scaleExtent([maxZoom, minZoom]);
|
|
2105
2124
|
this.zoom.on('zoom end', this.zoomed);
|
|
2106
|
-
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2107
|
-
if (((
|
|
2125
|
+
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2126
|
+
if (((_x = (_w = this.config) === null || _w === void 0 ? void 0 : _w.zoom) === null || _x === void 0 ? void 0 : _x.zoomBehavior) === ZoomBehaviorType.wheel) {
|
|
2108
2127
|
this.runWheelTranslate();
|
|
2109
2128
|
}
|
|
2110
2129
|
}
|
|
@@ -2414,8 +2433,6 @@ class CrosshairComponent {
|
|
|
2414
2433
|
}
|
|
2415
2434
|
ngOnInit() {
|
|
2416
2435
|
this.transform = this.chartService.pointerMove.pipe(map((event) => {
|
|
2417
|
-
const composedPath = event.composedPath();
|
|
2418
|
-
const classes = composedPath.map((_) => { var _a; return (_a = _.classList) === null || _a === void 0 ? void 0 : _a.contains('crosshair'); }).filter((_) => _);
|
|
2419
2436
|
return {
|
|
2420
2437
|
x: event.type === 'mouseleave' ? -9999 : event.offsetX,
|
|
2421
2438
|
y: event.type === 'mouseleave' ? -9999 : event.offsetY
|