From b65b04c5742847b58d5e8a985ab29daf91ba00cf Mon Sep 17 00:00:00 2001 From: vargburz Date: Tue, 24 May 2022 16:41:07 +0300 Subject: [PATCH] use core 060 --- src/index.ts | 40 ++++++++++++++++++++-------------------- yarn.lock | 6 +++--- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/index.ts b/src/index.ts index b1e8dd2..70ec9c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,7 @@ export class LinePod extends ChartwerkPod { constructor(_el: HTMLElement, _series: LineTimeSerie[] = [], _options: LineOptions = {}) { super(_el, _series, _options); - this.coreSeries = new LineSeries(_series); + this.series = new LineSeries(_series); } renderMetrics(): void { @@ -27,12 +27,12 @@ export class LinePod extends ChartwerkPod { this.initLineGenerator(); this.initAreaGenerator(); - if(!this.coreSeries.isSeriesAvailable) { + if(!this.series.isSeriesAvailable) { this.renderNoDataPointsMessage(); return; } - for(const serie of this.coreSeries.visibleSeries) { + for(const serie of this.series.visibleSeries) { this._renderMetric(serie); } } @@ -111,7 +111,7 @@ export class LinePod extends ChartwerkPod { appendCrosshairCircles(): void { // circle for each serie - this.coreSeries.visibleSeries.forEach((serie: LineTimeSerie, serieIdx: number) => { + this.series.visibleSeries.forEach((serie: LineTimeSerie, serieIdx: number) => { this.appendCrosshairCircle(serieIdx); }); } @@ -124,7 +124,7 @@ export class LinePod extends ChartwerkPod { .attr('cx', -CROSSHAIR_BACKGROUND_RAIDUS) .attr('cy', -CROSSHAIR_BACKGROUND_RAIDUS) .attr('clip-path', `url(#${this.rectClipId})`) - .attr('fill', this.coreSeries.visibleSeries[serieIdx].color) + .attr('fill', this.series.visibleSeries[serieIdx].color) .style('opacity', CROSSHAIR_BACKGROUND_OPACITY) .style('pointer-events', 'none'); @@ -134,7 +134,7 @@ export class LinePod extends ChartwerkPod { .attr('cy', -CROSSHAIR_CIRCLE_RADIUS) .attr('class', `crosshair-circle-${serieIdx}`) .attr('clip-path', `url(#${this.rectClipId})`) - .attr('fill', this.coreSeries.visibleSeries[serieIdx].color) + .attr('fill', this.series.visibleSeries[serieIdx].color) .attr('r', CROSSHAIR_CIRCLE_RADIUS) .style('pointer-events', 'none'); } @@ -146,7 +146,7 @@ export class LinePod extends ChartwerkPod { this.moveCrosshairLine(eventX, eventY); const datapoints = this.findAndHighlightDatapoints(values.x, values.y); - this.coreOptions.callbackSharedCrosshairMove({ + this.options.callbackSharedCrosshairMove({ datapoints: datapoints, eventX, eventY }); @@ -157,7 +157,7 @@ export class LinePod extends ChartwerkPod { } moveCrosshairLine(xPosition: number, yPosition: number): void { - switch(this.coreOptions.crosshair.orientation) { + switch(this.options.crosshair.orientation) { case CrosshairOrientation.VERTICAL: this.crosshair.select('#crosshair-line-x') .attr('x1', xPosition) @@ -177,7 +177,7 @@ export class LinePod extends ChartwerkPod { .attr('y2', yPosition); return; default: - throw new Error(`Unknown type of crosshair orientaion: ${this.coreOptions.crosshair.orientation}`); + throw new Error(`Unknown type of crosshair orientaion: ${this.options.crosshair.orientation}`); } } @@ -205,7 +205,7 @@ export class LinePod extends ChartwerkPod { getClosestIndex(datapoints: [number, number][], xValue: number, yValue: number): number { let columnIdx; // 0 for x value, 1 for y value, let value; // xValue to y Value - switch(this.coreOptions.crosshair.orientation) { + switch(this.options.crosshair.orientation) { case CrosshairOrientation.VERTICAL: columnIdx = 0; value = xValue; @@ -219,7 +219,7 @@ export class LinePod extends ChartwerkPod { columnIdx = 1; value = yValue; default: - throw new Error(`Unknown type of crosshair orientaion: ${this.coreOptions.crosshair.orientation}`); + throw new Error(`Unknown type of crosshair orientaion: ${this.options.crosshair.orientation}`); } // TODO: d3.bisect is not the best way. Use binary search @@ -248,7 +248,7 @@ export class LinePod extends ChartwerkPod { // columnIdx: 1 for y, 0 for x // inverval: x/y value interval between data points // TODO: move it to base/state instead of timeInterval - const intervals = _.map(this.coreSeries.visibleSeries, serie => { + const intervals = _.map(this.series.visibleSeries, serie => { if(serie.datapoints.length < 2) { return undefined; } @@ -272,7 +272,7 @@ export class LinePod extends ChartwerkPod { // TDOO: is shift key pressed // TODO: need to refactor this object - this.coreOptions.callbackMouseMove({ + this.options.callbackMouseMove({ x: d3.event.pageX, y: d3.event.pageY, xVal: xValue, @@ -284,11 +284,11 @@ export class LinePod extends ChartwerkPod { } findAndHighlightDatapoints(xValue: number, yValue: number): { value: [number, number], color: string, label: string }[] { - if(!this.coreSeries.isSeriesAvailable) { + if(!this.series.isSeriesAvailable) { return []; } let points = []; // datapoints in each metric that is closest to xValue/yValue position - this.coreSeries.visibleSeries.forEach((serie: LineTimeSerie) => { + this.series.visibleSeries.forEach((serie: LineTimeSerie) => { const closestDatapoint = this.getClosestDatapoint(serie, xValue, yValue); if(closestDatapoint === undefined) { this.hideCrosshairCircle(serie.idx); @@ -315,21 +315,21 @@ export class LinePod extends ChartwerkPod { } onMouseOut(): void { - this.coreOptions.callbackMouseOut(); + this.options.callbackMouseOut(); this.crosshair.style('display', 'none'); } isDoubleClickActive(): boolean { - return this.coreOptions.doubleClickEvent.isActive; + return this.options.doubleClickEvent.isActive; } - // methods below rewrite cores, (move more methods here) + // methods below rewrite s, (move more methods here) protected zoomOut(): void { if(d3.event.type === 'dblclick' && !this.isDoubleClickActive()) { return; } // TODO: its not clear, why we use this orientation here. Mb its better to use separate option - const orientation: BrushOrientation = this.coreOptions.mouseZoomEvent.orientation; + const orientation: BrushOrientation = this.options.mouseZoomEvent.orientation; const xInterval = this.state.xValueRange[1] - this.state.xValueRange[0]; const yInterval = this.state.yValueRange[1] - this.state.yValueRange[0]; switch(orientation) { @@ -364,7 +364,7 @@ export class LinePod extends ChartwerkPod { x: xAxisMiddleValue, y: yAxisMiddleValue } - this.coreOptions.callbackZoomOut(centers); + this.options.callbackZoomOut(centers); } } diff --git a/yarn.lock b/yarn.lock index edf1642..4aec6d8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,12 +6,12 @@ __metadata: cacheKey: 8 "@chartwerk/core@npm:latest": - version: 0.5.8 - resolution: "@chartwerk/core@npm:0.5.8" + version: 0.6.0 + resolution: "@chartwerk/core@npm:0.6.0" dependencies: d3: ^5.7.2 lodash: ^4.14.149 - checksum: 24b403af2703cc99ef3dee4793318ed71f4b02ed50bee6940774ccb392b8fbb53bb5353e91903b2c1ec815a8d2b830f2a2a2925d8e4380c64895ee2002b2baed + checksum: db368ea1ba1f9b48583c3da953998206329ea552eaff4e9f13cb02b25e0289464eca268baa86f045d62552a0859fc3ee2ccf70e7df95b58327bba217f9888169 languageName: node linkType: hard