@@ -68,6 +68,7 @@ export class LineChartService {
68
68
private _labelGroupHeight : number ;
69
69
private _legendGroupTop : number = this . _margin . top + this . _height + 50 ;
70
70
private _legendGroupLeft : number = this . _margin . left ;
71
+ private _legendGroupHeight ;
71
72
private _legendGroupColumnWidth ;
72
73
private _legendGroupColumns ;
73
74
private legendDataMap : Object = { } ;
@@ -108,9 +109,9 @@ export class LineChartService {
108
109
let chart : D3Selection < D3BaseType , { } , D3ContainerElement , { } > = d3Select ( 'g#time-series-chart-drawing-area' ) ;
109
110
let xScale : D3ScaleTime < number , number > = this . getXScale ( data ) ;
110
111
let yScale : D3ScaleLinear < number , number > = this . getYScale ( data ) ;
111
- let labelGroupHeight : number = this . getLegendHeight ( ) ;
112
+ this . calculateLegendDimensions ( ) ;
112
113
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 ) ;
114
115
d3Select ( '.x-axis' ) . transition ( ) . call ( this . updateXAxis , xScale ) ;
115
116
d3Select ( '.y-axis' ) . transition ( ) . call ( this . updateYAxis , yScale , this . _width , this . _margin ) ;
116
117
this . brush = d3BrushX ( ) . extent ( [ [ 0 , 0 ] , [ this . _width , this . _height ] ] ) ;
@@ -248,7 +249,7 @@ export class LineChartService {
248
249
. nice ( ) ;
249
250
}
250
251
251
- private getLegendHeight ( ) : number {
252
+ private calculateLegendDimensions ( ) : void {
252
253
let maximumLabelWidth : number = 1 ;
253
254
let labels = Object . keys ( this . legendDataMap ) ;
254
255
@@ -264,7 +265,7 @@ export class LineChartService {
264
265
. each ( ( datum , index , groups ) => {
265
266
Array . from ( groups ) . forEach ( ( text ) => {
266
267
if ( text ) {
267
- maximumLabelWidth = Math . max ( maximumLabelWidth , text . clientWidth )
268
+ maximumLabelWidth = Math . max ( maximumLabelWidth , text . getBoundingClientRect ( ) . width )
268
269
}
269
270
} ) ;
270
271
} ) ;
@@ -273,8 +274,7 @@ export class LineChartService {
273
274
274
275
this . _legendGroupColumnWidth = maximumLabelWidth + ChartCommons . COLOR_PREVIEW_SIZE + 30 ;
275
276
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 ;
278
278
}
279
279
280
280
private getMaxValue ( data : TimeSeries [ ] ) : number {
0 commit comments