@@ -136,31 +136,15 @@ export class LineChartService {
136136 */
137137 public setLegendData ( incomingData : EventResultDataDTO ) {
138138 let labelDataMap = { } ;
139- let translateMeasurands : boolean = incomingData . summaryLabels . length > 0 && incomingData . summaryLabels [ 0 ] . key != "measurand" ;
140139 incomingData . series . forEach ( ( data : EventResultSeriesDTO ) => {
141- if ( translateMeasurands ) {
142- let splitLabelList : string [ ] = data . identifier . split ( ' | ' , 2 ) ;
143- this . translationService
144- . get ( 'frontend.de.iteratec.isr.measurand.' + splitLabelList [ 0 ] )
145- . pipe ( take ( 1 ) )
146- . subscribe ( ( splitLabel : string ) => {
147- if ( ! splitLabel . startsWith ( 'frontend.de.iteratec.isr.measurand.' ) ) {
148- splitLabelList [ 0 ] = splitLabel ;
149- }
150- let key = this . generateKey ( data ) ;
151- labelDataMap [ key ] = {
152- text : splitLabelList . join ( ' | ' ) ,
153- key : key ,
154- show : true ,
155- }
156- } ) ;
157- } else {
158- let key = this . generateKey ( data ) ;
159- labelDataMap [ key ] = {
160- text : data . identifier ,
161- key : key ,
162- show : true ,
163- }
140+ if ( incomingData . summaryLabels . length > 0 && incomingData . summaryLabels [ 0 ] . key != "measurand" ) {
141+ data . identifier = this . translateMeasurand ( data ) ;
142+ }
143+ let key = this . generateKey ( data ) ;
144+ labelDataMap [ key ] = {
145+ text : data . identifier ,
146+ key : key ,
147+ show : true
164148 }
165149 } ) ;
166150 this . legendDataMap = labelDataMap ;
@@ -170,25 +154,36 @@ export class LineChartService {
170154 * Prepares the incoming data for drawing with D3.js
171155 */
172156 private prepareData ( incomingData : EventResultDataDTO ) : TimeSeries [ ] {
173-
174157 return incomingData . series . map ( ( data : EventResultSeriesDTO ) => {
175158 let lineChartData : TimeSeries = new TimeSeries ( ) ;
159+ if ( incomingData . summaryLabels . length > 0 && incomingData . summaryLabels [ 0 ] . key != "measurand" ) {
160+ data . identifier = this . translateMeasurand ( data ) ;
161+ }
176162 lineChartData . key = this . generateKey ( data ) ;
177163
178164 lineChartData . values = data . data . map ( ( point : EventResultPointDTO ) => {
179165 let lineChartDataPoint : TimeSeriesPoint = new TimeSeriesPoint ( ) ;
180166 lineChartDataPoint . date = parseDate ( point . date ) ;
181167 lineChartDataPoint . value = point . value ;
182- lineChartDataPoint . tooltipText = data . jobGroup + ' | ' + data . measuredEvent + ' : '; // TODO Set exact label text when IT-2793 is implemented
168+ lineChartDataPoint . tooltipText = data . identifier + ' : ' ;
183169 return lineChartDataPoint ;
184170 } ) ;
185171
186172 return lineChartData ;
187173 } ) ;
188174 }
189175
176+ private translateMeasurand ( data : EventResultSeriesDTO ) : string {
177+ let splitLabelList : string [ ] = data . identifier . split ( ' | ' ) ;
178+ let splitLabel : string = this . translationService . instant ( 'frontend.de.iteratec.isr.measurand.' + splitLabelList [ 0 ] ) ;
179+ if ( ! splitLabel . startsWith ( 'frontend.de.iteratec.isr.measurand.' ) ) {
180+ splitLabelList [ 0 ] = splitLabel ;
181+ }
182+ return splitLabelList . join ( ' | ' ) ;
183+ }
184+
190185 private generateKey ( data : EventResultSeriesDTO ) : string {
191- return data . identifier . split ( ' | ' ) . join ( ) . split ( ':' ) . join ( "" ) ;
186+ return data . identifier . split ( ' | ' ) . join ( ) . split ( ':' ) . join ( "" ) . split ( "?" ) . join ( "" ) ;
192187 }
193188
194189 /**
@@ -576,7 +571,7 @@ export class LineChartService {
576571 } )
577572 // fade in
578573 . transition ( ) . duration ( 500 ) . style ( 'opacity' , ( timeSeries : TimeSeries ) => {
579- return ( this . legendDataMap [ timeSeries . key ] . show ) ? '1' : '0.2 ' ;
574+ return ( this . legendDataMap [ timeSeries . key ] . show ) ? '1' : '0.1 ' ;
580575 } ) ;
581576
582577 return resultingSelection ;
0 commit comments