Skip to content

Commit f786981

Browse files
Apply suggestions from code review
Fix legend dimensions in Firefox. Co-Authored-By: Johannes Weiß <johannes.weiss@iteratec.com>
1 parent 65acade commit f786981

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class LineChartService {
6868
private _labelGroupHeight: number;
6969
private _legendGroupTop: number = this._margin.top + this._height + 50;
7070
private _legendGroupLeft: number = this._margin.left;
71+
private _legendGroupHeight;
7172
private _legendGroupColumnWidth;
7273
private _legendGroupColumns;
7374
private legendDataMap: Object = {};
@@ -108,9 +109,9 @@ export class LineChartService {
108109
let chart: D3Selection<D3BaseType, {}, D3ContainerElement, {}> = d3Select('g#time-series-chart-drawing-area');
109110
let xScale: D3ScaleTime<number, number> = this.getXScale(data);
110111
let yScale: D3ScaleLinear<number, number> = this.getYScale(data);
111-
let labelGroupHeight: number = this.getLegendHeight();
112+
this.calculateLegendDimensions();
112113
d3Select('osm-time-series-line-chart').transition().duration(500).style('visibility', 'visible');
113-
d3Select('svg#time-series-chart').transition().duration(500).attr('height', this._height + labelGroupHeight + this._margin.top + this._margin.bottom);
114+
d3Select('svg#time-series-chart').transition().duration(500).attr('height', this._height + this._legendGroupHeight + this._margin.top + this._margin.bottom);
114115
d3Select('.x-axis').transition().call(this.updateXAxis, xScale);
115116
d3Select('.y-axis').transition().call(this.updateYAxis, yScale, this._width, this._margin);
116117
this.brush = d3BrushX().extent([[0, 0], [this._width, this._height]]);
@@ -248,7 +249,7 @@ export class LineChartService {
248249
.nice();
249250
}
250251

251-
private getLegendHeight(): number {
252+
private calculateLegendDimensions(): void {
252253
let maximumLabelWidth: number = 1;
253254
let labels = Object.keys(this.legendDataMap);
254255

@@ -264,7 +265,7 @@ export class LineChartService {
264265
.each((datum, index, groups) => {
265266
Array.from(groups).forEach((text) => {
266267
if (text) {
267-
maximumLabelWidth = Math.max(maximumLabelWidth, text.clientWidth)
268+
maximumLabelWidth = Math.max(maximumLabelWidth, text.getBoundingClientRect().width)
268269
}
269270
});
270271
});
@@ -273,8 +274,7 @@ export class LineChartService {
273274

274275
this._legendGroupColumnWidth = maximumLabelWidth + ChartCommons.COLOR_PREVIEW_SIZE + 30;
275276
this._legendGroupColumns = Math.floor(this._width / this._legendGroupColumnWidth);
276-
277-
return Math.ceil(labels.length / this._legendGroupColumns) * ChartCommons.LABEL_HEIGHT + 30;
277+
this._legendGroupHeight = Math.ceil(labels.length / this._legendGroupColumns) * ChartCommons.LABEL_HEIGHT + 30;
278278
}
279279

280280
private getMaxValue(data: TimeSeries[]): number {

0 commit comments

Comments
 (0)