@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
|
@@ -121,6 +121,7 @@ var ClipPointsDirection;
|
|
|
121
121
|
(function (ClipPointsDirection) {
|
|
122
122
|
ClipPointsDirection[ClipPointsDirection["x"] = 0] = "x";
|
|
123
123
|
ClipPointsDirection[ClipPointsDirection["y"] = 1] = "y";
|
|
124
|
+
ClipPointsDirection[ClipPointsDirection["none"] = 2] = "none";
|
|
124
125
|
})(ClipPointsDirection || (ClipPointsDirection = {}));
|
|
125
126
|
|
|
126
127
|
const defaultSeriesConfig = () => ({
|
|
@@ -423,7 +424,7 @@ class ZoomService {
|
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
426
|
getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
|
|
426
|
-
const zoomScale = Math.abs(originalDomain[1] - originalDomain[0]) / Math.abs(targetDomain[1] - targetDomain[0]);
|
|
427
|
+
const zoomScale = Math.abs(scale(originalDomain[1]) - scale(originalDomain[0])) / Math.abs(scale(targetDomain[1]) - scale(targetDomain[0]));
|
|
427
428
|
let transform = zoomIdentity.scale(zoomScale);
|
|
428
429
|
if (orientation === AxisOrientation.x) {
|
|
429
430
|
if (!!inverted) {
|
|
@@ -860,7 +861,7 @@ class LinearSeriesBase extends SeriesBaseComponent {
|
|
|
860
861
|
}
|
|
861
862
|
set series(series) {
|
|
862
863
|
this.__series = series;
|
|
863
|
-
this.markers = this.__series.data?.filter((_) => _?.marker && _?.x !== undefined && _?.y !== undefined);
|
|
864
|
+
this.markers = this.__series.data?.filter((_) => _?.marker && _?.x !== undefined && _?.y !== undefined && _?.x !== null && _?.y !== null);
|
|
864
865
|
}
|
|
865
866
|
get series() {
|
|
866
867
|
return this.__series;
|
|
@@ -1587,12 +1588,13 @@ class XAxisComponent {
|
|
|
1587
1588
|
constructor(scaleService, _svc) {
|
|
1588
1589
|
this.scaleService = scaleService;
|
|
1589
1590
|
this._svc = _svc;
|
|
1591
|
+
this.update$ = new BehaviorSubject(null);
|
|
1590
1592
|
this._alive = true;
|
|
1591
1593
|
this.x = this.scaleService.scales.pipe(map((_) => {
|
|
1592
1594
|
return _.x.get(this.axis.index)?.scale;
|
|
1593
1595
|
}));
|
|
1594
|
-
this.ticks = this.x.pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1595
|
-
const [x, size] = _;
|
|
1596
|
+
this.ticks = combineLatest([this.x, this.update$]).pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1597
|
+
const [[x], size] = _;
|
|
1596
1598
|
const tickSize = x.ticks().map((_) => getTextWidth(this.axis.options.tickFormat ? this.axis.options.tickFormat(_) : this.axis.defaultFormatter()(_), 0.45, 11));
|
|
1597
1599
|
return x.ticks(size.width / parseInt(d3.max(tickSize), 10) / 10);
|
|
1598
1600
|
}));
|
|
@@ -1605,9 +1607,14 @@ class XAxisComponent {
|
|
|
1605
1607
|
ngOnDestroy() {
|
|
1606
1608
|
this._alive = false;
|
|
1607
1609
|
}
|
|
1610
|
+
ngOnChanges(changes) {
|
|
1611
|
+
if (changes.hasOwnProperty('axis')) {
|
|
1612
|
+
this.update$.next();
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1608
1615
|
}
|
|
1609
1616
|
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 });
|
|
1610
|
-
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 });
|
|
1617
|
+
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 });
|
|
1611
1618
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, decorators: [{
|
|
1612
1619
|
type: Component,
|
|
1613
1620
|
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"] }]
|
|
@@ -2060,10 +2067,22 @@ class ZoomableDirective {
|
|
|
2060
2067
|
[0, 0],
|
|
2061
2068
|
[this.size.width, this.size.height],
|
|
2062
2069
|
]);
|
|
2063
|
-
|
|
2070
|
+
const min = this.config?.zoom?.minTranslate
|
|
2071
|
+
? this.axis.scale(this.config?.zoom?.minTranslate)
|
|
2072
|
+
: -Infinity;
|
|
2073
|
+
const max = (this.config?.zoom?.maxTranslate
|
|
2074
|
+
? this.axis.scale(this.config?.zoom?.maxTranslate) - (this.axis.orientation === AxisOrientation.x ? this.size.width : this.size.height)
|
|
2075
|
+
: Infinity);
|
|
2076
|
+
if (this.axis.orientation === AxisOrientation.x && this.config.zoom.type === ZoomType.x) {
|
|
2077
|
+
this.zoom.translateExtent([
|
|
2078
|
+
[min, -Infinity],
|
|
2079
|
+
[max, Infinity],
|
|
2080
|
+
]);
|
|
2081
|
+
}
|
|
2082
|
+
if (this.axis.orientation === AxisOrientation.y && this.config.zoom.type === ZoomType.y) {
|
|
2064
2083
|
this.zoom.translateExtent([
|
|
2065
|
-
[
|
|
2066
|
-
[
|
|
2084
|
+
[-Infinity, min],
|
|
2085
|
+
[Infinity, max],
|
|
2067
2086
|
]);
|
|
2068
2087
|
}
|
|
2069
2088
|
if (this.config.zoom?.wheelDelta) {
|
|
@@ -2081,7 +2100,7 @@ class ZoomableDirective {
|
|
|
2081
2100
|
: Infinity;
|
|
2082
2101
|
this.zoom.scaleExtent([maxZoom, minZoom]);
|
|
2083
2102
|
this.zoom.on('zoom end', this.zoomed);
|
|
2084
|
-
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2103
|
+
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2085
2104
|
if (this.config?.zoom?.zoomBehavior === ZoomBehaviorType.wheel) {
|
|
2086
2105
|
this.runWheelTranslate();
|
|
2087
2106
|
}
|
|
@@ -2387,8 +2406,6 @@ class CrosshairComponent {
|
|
|
2387
2406
|
}
|
|
2388
2407
|
ngOnInit() {
|
|
2389
2408
|
this.transform = this.chartService.pointerMove.pipe(map((event) => {
|
|
2390
|
-
const composedPath = event.composedPath();
|
|
2391
|
-
const classes = composedPath.map((_) => _.classList?.contains('crosshair')).filter((_) => _);
|
|
2392
2409
|
return {
|
|
2393
2410
|
x: event.type === 'mouseleave' ? -9999 : event.offsetX,
|
|
2394
2411
|
y: event.type === 'mouseleave' ? -9999 : event.offsetY
|