@@ -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