Skip to content

Commit 08de190

Browse files
author
Gustavo Antonio Lastra Colorado
committed
[IT-2793] edit code structure
1 parent 4b48fe6 commit 08de190

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

frontend/src/app/modules/time-series/components/time-series-line-chart/time-series-line-chart.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export class TimeSeriesLineChartComponent implements AfterContentInit, OnChanges
5050

5151
redraw() {
5252
this.lineChartService.initLegendData(this.timeSeriesResults);
53-
this.lineChartService.drawLegends(this.timeSeriesResults);
5453
this.lineChartService.drawLineChart(this.timeSeriesResults);
5554
}
5655

frontend/src/app/modules/time-series/services/line-chart.service.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,21 @@ export class LineChartService {
8989
return;
9090
}
9191

92-
9392
this._labelGroupHeight = data.length * this._labelHeight;
94-
9593
d3Select('osm-time-series-line-chart').transition().duration(500).style('visibility', 'visible');
9694
d3Select('svg#time-series-svg').transition().duration(500).attr('height', this._height + this._labelGroupHeight + this._margin.top + this._margin.bottom);
9795
let chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}> = d3Select('g#time-series-chart-drawing-area');
9896
let xScale: D3ScaleTime<number, number> = this.getXScale(data);
9997
let yScale: D3ScaleLinear<number, number> = this.getYScale(data);
10098
d3Select('.x-axis').transition().call(this.updateXAxis, xScale);
10199
d3Select('.y-axis').transition().call(this.updateYAxis, yScale, this._width, this._margin);
100+
this.addLegendsToChart(chart, incomingData);
102101
this.addDataLinesToChart(chart, xScale, yScale, data);
103102
}
104103

104+
/**
105+
* Initialize Label's Datamap after the incoming data is received
106+
*/
105107
public initLegendData(incomingData: EventResultDataDTO){
106108
const TimeSeriesSVG = d3Select("#time-series-svg");
107109
let labelDataMap= {}
@@ -121,11 +123,6 @@ export class LineChartService {
121123
this.legendDataMap=labelDataMap;
122124
}
123125

124-
public drawLegends(incomingData: EventResultDataDTO): void {
125-
let chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}> = d3Select('g#time-series-chart-drawing-area');
126-
this.addLegendsToChart(chart, incomingData)
127-
}
128-
129126
/**
130127
* Prepares the incoming data for drawing with D3.js
131128
*/
@@ -159,7 +156,6 @@ export class LineChartService {
159156
private createChart(svgElement: ElementRef): D3Selection<D3BaseType, {}, D3ContainerElement, {}> {
160157

161158
this._width = svgElement.nativeElement.parentElement.offsetWidth - this._margin.left - this._margin.right;
162-
//this._height = svgElement.nativeElement.parentElement.offsetHeight - this._margin.top - this._margin.bottom;
163159
const svg = d3Select(svgElement.nativeElement)
164160
.attr('id', 'time-series-svg')
165161
.attr('width', this._width + this._margin.left + this._margin.right)
@@ -355,7 +351,6 @@ export class LineChartService {
355351
return yScale(point.value);
356352
}) // ... and for the Y-Coordinate
357353
.curve(d3CurveMonotoneX); // smooth the line
358-
359354
}
360355

361356
/**
@@ -427,7 +422,7 @@ export class LineChartService {
427422
.attr("rx", 2)
428423
.attr("ry", 2)
429424
.attr("ry", 2)
430-
.attr('fill', (d, index: number) => { return getColorScheme()[index]; });
425+
.attr('fill', (d, index: number) => { return getColorScheme()[index]});
431426
legendElement
432427
.append('text')
433428
.attr('class', 'legend-text')
@@ -478,7 +473,6 @@ export class LineChartService {
478473
}
479474
});
480475
}
481-
this.drawLegends(incomingData);
482476
this.drawLineChart(incomingData);
483477
}
484478

0 commit comments

Comments
 (0)