Skip to content

Commit f7c8d15

Browse files
authored
Merge pull request #284 from iteratec/feature/addTimeSeriesLegends
Feature/add time series legends
2 parents 925cf72 + b971f11 commit f7c8d15

File tree

5 files changed

+162
-58
lines changed

5 files changed

+162
-58
lines changed

frontend/src/app/enums/chart-commons.enum.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export enum ChartCommons {
55
COMPONENT_MARGIN = 15,
66
CHART_HEADER_HEIGHT = 40,
77
COLOR_PREVIEW_SIZE = 10,
8-
COLOR_PREVIEW_MARGIN = 5
8+
COLOR_PREVIEW_MARGIN = 5,
9+
LABEL_HEIGHT = 30
910
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<div class="time-series-line-chart-container">
22
<div class="card">
3-
<svg #svg>
4-
<g class="time-series-chart"></g>
5-
</svg>
3+
<svg #svg />
64
</div>
75
</div>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ osm-time-series-line-chart {
1313
line {
1414
stroke: $color-contour-medium;
1515
}
16+
1617
text {
1718
fill: $color-text-light;
1819
}

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {LineChartService} from '../../services/line-chart.service';
1818
selector: 'osm-time-series-line-chart',
1919
encapsulation: ViewEncapsulation.None, // needed! otherwise the scss style do not apply to svg content (see https://stackoverflow.com/questions/36214546/styles-in-component-for-d3-js-do-not-show-in-angular-2/36214723#36214723)
2020
templateUrl: './time-series-line-chart.component.html',
21-
styleUrls: [ './time-series-line-chart.component.scss' ]
21+
styleUrls: ['./time-series-line-chart.component.scss']
2222
})
2323
export class TimeSeriesLineChartComponent implements AfterContentInit, OnChanges {
2424

@@ -32,13 +32,22 @@ export class TimeSeriesLineChartComponent implements AfterContentInit, OnChanges
3232

3333
constructor(
3434
private lineChartService: LineChartService
35-
) {}
35+
) {
36+
}
37+
38+
ngAfterContentInit(): void {
39+
this.lineChartService.initChart(this.svgElement);
40+
}
41+
42+
ngOnChanges(changes: SimpleChanges): void {
43+
this.redraw();
44+
}
3645

3746
@HostListener('window:resize', ['$event'])
3847
windowIsResized() {
3948
this.lineChartService.startResize(this.svgElement);
4049

41-
// Wati until the resize is done before redrawing the chart
50+
// Wait until the resize is done before redrawing the chart
4251
clearTimeout(this._resizeTimeoutId);
4352
this._resizeTimeoutId = window.setTimeout(() => {
4453
this.lineChartService.resizeChart(this.svgElement);
@@ -49,15 +58,7 @@ export class TimeSeriesLineChartComponent implements AfterContentInit, OnChanges
4958
}
5059

5160
redraw() {
61+
this.lineChartService.setLegendData(this.timeSeriesResults);
5262
this.lineChartService.drawLineChart(this.timeSeriesResults);
5363
}
54-
55-
ngAfterContentInit(): void {
56-
this.lineChartService.initChart(this.svgElement);
57-
}
58-
59-
ngOnChanges(changes: SimpleChanges): void {
60-
this.redraw();
61-
}
62-
6364
}

0 commit comments

Comments
 (0)