@@ -89,6 +89,7 @@ export class LineChartService {
8989 return ;
9090 }
9191
92+
9293 this . _labelGroupHeight = data . length * this . _labelHeight ;
9394
9495 d3Select ( 'osm-time-series-line-chart' ) . transition ( ) . duration ( 500 ) . style ( 'visibility' , 'visible' ) ;
@@ -101,16 +102,13 @@ export class LineChartService {
101102 this . addDataLinesToChart ( chart , xScale , yScale , data ) ;
102103 }
103104
104- public initLegendData ( ) {
105+ public initLegendData ( incomingData : EventResultDataDTO ) {
105106 const TimeSeriesSVG = d3Select ( "#time-series-svg" ) ;
107+ let labelDataMap = { }
106108 TimeSeriesSVG . append ( 'g' )
107109 . attr ( 'class' , 'legend-group' )
108110 . attr ( 'transform' , `translate(${ this . _legendGroupLeft } , ${ this . _legendGroupTop } )` )
109- }
110111
111- public drawLegends ( incomingData : EventResultDataDTO ) : void {
112- let labelDataMap = { }
113- let chart : D3Selection < D3BaseType , { } , D3ContainerElement , { } > = d3Select ( 'g#time-series-chart-drawing-area' ) ;
114112 incomingData . series . forEach ( ( data : EventResultSeriesDTO ) => {
115113 let label = data . identifier ;
116114 let key = this . generateKey ( data ) ;
@@ -120,8 +118,12 @@ export class LineChartService {
120118 show : true ,
121119 }
122120 } ) ;
123- this . legendDataMap = labelDataMap ;
124- this . addIdentifierLegendsToChart ( chart , incomingData )
121+ this . legendDataMap = labelDataMap ;
122+ }
123+
124+ public drawLegends ( incomingData : EventResultDataDTO ) : void {
125+ let chart : D3Selection < D3BaseType , { } , D3ContainerElement , { } > = d3Select ( 'g#time-series-chart-drawing-area' ) ;
126+ this . addLegendsToChart ( chart , incomingData )
125127 }
126128
127129 /**
@@ -391,10 +393,10 @@ export class LineChartService {
391393 . append ( 'g' ) // Group each line so we can add dots to this group latter
392394 . append ( 'path' ) // Draw one path for every item in the data set
393395 . attr ( 'fill' , 'none' )
394- . attr ( 'stroke' , ( d , index : number ) => { return getColorScheme ( ) [ index ] ; /*console.log("d: " + JSON.stringify(d));*/ /*this.legendDataMap[d].color*/ /*this.legendDataMap[d].color; getColorScheme()[index];*/ } )
396+ . attr ( 'stroke' , ( d , index : number ) => { return getColorScheme ( ) [ index ] ; } )
395397 . attr ( 'stroke-width' , 1.5 )
396398 . style ( 'opacity' , ( d ) => {
397- return ( this . legendDataMap [ d . key ] . show ) ? 1 : 0.1 ;
399+ return ( this . legendDataMap [ d . key ] . show ) ? 1 : 0.2 ;
398400 } )
399401 . attr ( 'd' , ( dataItem : TimeSeries ) => {
400402 return this . getLineGenerator ( xScale , yScale ) ( dataItem . values ) ;
@@ -408,7 +410,7 @@ export class LineChartService {
408410 } ) ;
409411 }
410412
411- private addIdentifierLegendsToChart ( chart : D3Selection < D3BaseType , { } , D3ContainerElement , { } > ,
413+ private addLegendsToChart ( chart : D3Selection < D3BaseType , { } , D3ContainerElement , { } > ,
412414 incomingData : EventResultDataDTO ) {
413415 chart . selectAll ( '.legend-entry' ) . remove ( ) ;
414416 const legendEntry = d3Select ( '.legend-group' ) . selectAll ( '.legend-entry' ) . data ( Object . keys ( this . legendDataMap ) ) ;
@@ -439,7 +441,7 @@ export class LineChartService {
439441 . transition ( )
440442 . duration ( ChartCommons . TRANSITION_DURATION )
441443 . style ( 'opacity' , ( datum ) => {
442- return ( this . legendDataMap [ datum ] . show ) ? 1 : 0.1 ;
444+ return ( this . legendDataMap [ datum ] . show ) ? 1 : 0.2 ;
443445 } ) ;
444446 return update ;
445447 } ,
@@ -476,8 +478,8 @@ export class LineChartService {
476478 }
477479 } ) ;
478480 }
479- this . drawLineChart ( incomingData ) ;
480481 this . drawLegends ( incomingData ) ;
482+ this . drawLineChart ( incomingData ) ;
481483 }
482484
483485 //private addDataPointsToChart(chartLineGroups: D3Selection<any, LineChartDataDTO, D3ContainerElement, {}>,
0 commit comments