From a8cfbc1115c8c633206bd5efb440ef410f8ad703 Mon Sep 17 00:00:00 2001 From: vargburz Date: Thu, 28 Oct 2021 20:43:12 +0300 Subject: [PATCH] lineGenerator fix --- src/index.ts | 50 ++------------------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/src/index.ts b/src/index.ts index 15b1b10..7eeb961 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,8 +67,8 @@ export class LinePod extends ChartwerkPod { initLineGenerator(): void { this.lineGenerator = this.d3.line() - .x(d => this.xScale(d[1])) - .y(d => this.yScale(d[0])); + .x(d => this.xScale(d[0])) + .y(d => this.yScale(d[1])); } public appendData(data: [number, number][]): void { @@ -178,52 +178,6 @@ export class LinePod extends ChartwerkPod { if(metricOptions.renderDots === true) { this._renderDots(datapoints, metricOptions.serieIdx); } - - let upperBoundDatapoints = []; - let lowerBoundDatapoints = []; - if( - this.options.bounds !== undefined && - this.options.bounds.upper !== undefined && - this.options.bounds.lower !== undefined - ) { - this.series.forEach(serie => { - if(serie.target === this.formatedBound(this.options.bounds.upper, metricOptions.target)) { - upperBoundDatapoints = serie.datapoints; - } - if(serie.target === this.formatedBound(this.options.bounds.lower, metricOptions.target)) { - lowerBoundDatapoints = serie.datapoints; - } - }); - } - - if(upperBoundDatapoints.length > 0 && lowerBoundDatapoints.length > 0) { - const zip = (arr1, arr2) => arr1.map((k, i) => [k[0], k[1], arr2[i][1]]); - const data = zip(upperBoundDatapoints, lowerBoundDatapoints); - - this.metricContainer.append('path') - .datum(data) - .attr('fill', metricOptions.color) - .attr('stroke', 'none') - .attr('opacity', '0.3') - .attr('d', this.d3.area() - .x((d: number[]) => this.xScale(d[0])) - .y0((d: number[]) => this.yScale(d[1])) - .y1((d: number[]) => this.yScale(d[2])) - ) - } - - if(metricOptions.confidence > 0) { - this.metricContainer.append('path') - .datum(datapoints) - .attr('fill', metricOptions.color) - .attr('stroke', 'none') - .attr('opacity', '0.3') - .attr('d', this.d3.area() - .x((d: [number, number]) => this.xScale(d[0])) - .y0((d: [number, number]) => this.yScale(d[1] + metricOptions.confidence)) - .y1((d: [number, number]) => this.yScale(d[1] - metricOptions.confidence)) - ) - } } updateCrosshair(): void {