@tetacom/svg-charts 1.3.1 → 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/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/i-chart-config.mjs +1 -1
- package/esm2020/chart/service/zoom.service.mjs +2 -2
- package/fesm2015/tetacom-svg-charts.mjs +36 -20
- package/fesm2015/tetacom-svg-charts.mjs.map +1 -1
- package/fesm2020/tetacom-svg-charts.mjs +27 -11
- package/fesm2020/tetacom-svg-charts.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -424,7 +424,7 @@ class ZoomService {
|
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
getD3Transform(targetDomain, originalDomain, scale, orientation, inverted) {
|
|
427
|
-
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]));
|
|
428
428
|
let transform = zoomIdentity.scale(zoomScale);
|
|
429
429
|
if (orientation === AxisOrientation.x) {
|
|
430
430
|
if (!!inverted) {
|
|
@@ -861,7 +861,7 @@ class LinearSeriesBase extends SeriesBaseComponent {
|
|
|
861
861
|
}
|
|
862
862
|
set series(series) {
|
|
863
863
|
this.__series = series;
|
|
864
|
-
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);
|
|
865
865
|
}
|
|
866
866
|
get series() {
|
|
867
867
|
return this.__series;
|
|
@@ -1588,12 +1588,13 @@ class XAxisComponent {
|
|
|
1588
1588
|
constructor(scaleService, _svc) {
|
|
1589
1589
|
this.scaleService = scaleService;
|
|
1590
1590
|
this._svc = _svc;
|
|
1591
|
+
this.update$ = new BehaviorSubject(null);
|
|
1591
1592
|
this._alive = true;
|
|
1592
1593
|
this.x = this.scaleService.scales.pipe(map((_) => {
|
|
1593
1594
|
return _.x.get(this.axis.index)?.scale;
|
|
1594
1595
|
}));
|
|
1595
|
-
this.ticks = this.x.pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1596
|
-
const [x, size] = _;
|
|
1596
|
+
this.ticks = combineLatest([this.x, this.update$]).pipe(withLatestFrom(this._svc.size), map((_) => {
|
|
1597
|
+
const [[x], size] = _;
|
|
1597
1598
|
const tickSize = x.ticks().map((_) => getTextWidth(this.axis.options.tickFormat ? this.axis.options.tickFormat(_) : this.axis.defaultFormatter()(_), 0.45, 11));
|
|
1598
1599
|
return x.ticks(size.width / parseInt(d3.max(tickSize), 10) / 10);
|
|
1599
1600
|
}));
|
|
@@ -1606,9 +1607,14 @@ class XAxisComponent {
|
|
|
1606
1607
|
ngOnDestroy() {
|
|
1607
1608
|
this._alive = false;
|
|
1608
1609
|
}
|
|
1610
|
+
ngOnChanges(changes) {
|
|
1611
|
+
if (changes.hasOwnProperty('axis')) {
|
|
1612
|
+
this.update$.next();
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1609
1615
|
}
|
|
1610
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 });
|
|
1611
|
-
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 });
|
|
1612
1618
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.2", ngImport: i0, type: XAxisComponent, decorators: [{
|
|
1613
1619
|
type: Component,
|
|
1614
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"] }]
|
|
@@ -2061,10 +2067,22 @@ class ZoomableDirective {
|
|
|
2061
2067
|
[0, 0],
|
|
2062
2068
|
[this.size.width, this.size.height],
|
|
2063
2069
|
]);
|
|
2064
|
-
|
|
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) {
|
|
2065
2083
|
this.zoom.translateExtent([
|
|
2066
|
-
[
|
|
2067
|
-
[
|
|
2084
|
+
[-Infinity, min],
|
|
2085
|
+
[Infinity, max],
|
|
2068
2086
|
]);
|
|
2069
2087
|
}
|
|
2070
2088
|
if (this.config.zoom?.wheelDelta) {
|
|
@@ -2082,7 +2100,7 @@ class ZoomableDirective {
|
|
|
2082
2100
|
: Infinity;
|
|
2083
2101
|
this.zoom.scaleExtent([maxZoom, minZoom]);
|
|
2084
2102
|
this.zoom.on('zoom end', this.zoomed);
|
|
2085
|
-
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2103
|
+
this._element.call(this.zoom).on('dblclick.zoom', null);
|
|
2086
2104
|
if (this.config?.zoom?.zoomBehavior === ZoomBehaviorType.wheel) {
|
|
2087
2105
|
this.runWheelTranslate();
|
|
2088
2106
|
}
|
|
@@ -2388,8 +2406,6 @@ class CrosshairComponent {
|
|
|
2388
2406
|
}
|
|
2389
2407
|
ngOnInit() {
|
|
2390
2408
|
this.transform = this.chartService.pointerMove.pipe(map((event) => {
|
|
2391
|
-
const composedPath = event.composedPath();
|
|
2392
|
-
const classes = composedPath.map((_) => _.classList?.contains('crosshair')).filter((_) => _);
|
|
2393
2409
|
return {
|
|
2394
2410
|
x: event.type === 'mouseleave' ? -9999 : event.offsetX,
|
|
2395
2411
|
y: event.type === 'mouseleave' ? -9999 : event.offsetY
|