@@ -386,6 +386,7 @@ module powerbi.extensibility.visual {
386
386
private interactivityService : IInteractivityService ;
387
387
private tooltipServiceWrapper : ITooltipServiceWrapper ;
388
388
private host : IVisualHost ;
389
+ private localizationManager : ILocalizationManager ;
389
390
private isInteractiveChart : boolean = false ;
390
391
private groupTasksPrevValue : boolean = false ;
391
392
private collapsedTasks : string [ ] = [ ] ;
@@ -396,6 +397,7 @@ module powerbi.extensibility.visual {
396
397
397
398
private init ( options : VisualConstructorOptions ) : void {
398
399
this . host = options . host ;
400
+ this . localizationManager = this . host . createLocalizationManager ( ) ;
399
401
this . colors = options . host . colorPalette ;
400
402
this . selectionManager = options . host . createSelectionManager ( ) ;
401
403
this . body = d3 . select ( options . element ) ;
@@ -555,45 +557,52 @@ module powerbi.extensibility.visual {
555
557
public static getTooltipInfo (
556
558
task : Task ,
557
559
formatters : GanttChartFormatters ,
558
- durationUnit : string ) : VisualTooltipDataItem [ ] {
560
+ durationUnit : string ,
561
+ localizationManager : ILocalizationManager ) : VisualTooltipDataItem [ ] {
559
562
560
563
let tooltipDataArray : VisualTooltipDataItem [ ] = [ ] ;
561
- const durationLabel : string = Gantt . generateLabelForDuration ( task . duration , durationUnit ) ;
564
+ const durationLabel : string = Gantt . generateLabelForDuration ( task . duration , durationUnit , localizationManager ) ;
562
565
if ( task . taskType ) {
563
- tooltipDataArray . push ( { displayName : "Legend" , value : task . taskType } ) ;
566
+ tooltipDataArray . push ( {
567
+ displayName : localizationManager . getDisplayName ( "Role_Legend" ) ,
568
+ value : task . taskType
569
+ } ) ;
564
570
}
565
571
566
572
tooltipDataArray . push ( {
567
- displayName : "Task" ,
573
+ displayName : localizationManager . getDisplayName ( "Role_Task" ) ,
568
574
value : task . name
569
575
} ) ;
570
576
571
577
if ( ! isNaN ( task . start . getDate ( ) ) ) {
572
578
tooltipDataArray . push ( {
573
- displayName : "Start Date" ,
579
+ displayName : localizationManager . getDisplayName ( "Role_StartDate" ) ,
574
580
value : formatters . startDateFormatter . format ( task . start )
575
581
} ) ;
576
582
577
583
tooltipDataArray . push ( {
578
- displayName : "End Date" ,
584
+ displayName : localizationManager . getDisplayName ( "Role_EndDate" ) ,
579
585
value : formatters . startDateFormatter . format ( task . end )
580
586
} ) ;
581
587
}
582
588
583
589
tooltipDataArray . push ( {
584
- displayName : "Duration" ,
590
+ displayName : localizationManager . getDisplayName ( "Role_Duration" ) ,
585
591
value : durationLabel
586
592
} ) ;
587
593
588
594
if ( task . completion ) {
589
595
tooltipDataArray . push ( {
590
- displayName : "Completion" ,
596
+ displayName : localizationManager . getDisplayName ( "Role_Completion" ) ,
591
597
value : formatters . completionFormatter . format ( task . completion )
592
598
} ) ;
593
599
}
594
600
595
601
if ( task . resource ) {
596
- tooltipDataArray . push ( { displayName : "Resource" , value : task . resource } ) ;
602
+ tooltipDataArray . push ( {
603
+ displayName : localizationManager . getDisplayName ( "Role_Resource" ) ,
604
+ value : task . resource
605
+ } ) ;
597
606
}
598
607
599
608
if ( task . tooltipInfo && task . tooltipInfo . length ) {
@@ -740,7 +749,8 @@ module powerbi.extensibility.visual {
740
749
formatters : GanttChartFormatters ,
741
750
colors : IColorPalette ,
742
751
settings : GanttSettings ,
743
- taskColor : string ) : Task [ ] {
752
+ taskColor : string ,
753
+ localizationManager : ILocalizationManager ) : Task [ ] {
744
754
745
755
let tasks : Task [ ] = [ ] ;
746
756
const colorHelper : ColorHelper = new ColorHelper ( colors , Gantt . LegendPropertyIdentifier ) ;
@@ -902,7 +912,7 @@ module powerbi.extensibility.visual {
902
912
}
903
913
904
914
tasks . forEach ( ( task : Task ) => {
905
- task . tooltipInfo = Gantt . getTooltipInfo ( task , formatters , durationUnit ) ;
915
+ task . tooltipInfo = Gantt . getTooltipInfo ( task , formatters , durationUnit , localizationManager ) ;
906
916
} ) ;
907
917
908
918
return tasks ;
@@ -1133,7 +1143,8 @@ module powerbi.extensibility.visual {
1133
1143
*/
1134
1144
private static generateLabelForDuration (
1135
1145
duration : number ,
1136
- durationUnit : string | DurationUnits ) : string {
1146
+ durationUnit : string | DurationUnits ,
1147
+ localizationManager : ILocalizationManager ) : string {
1137
1148
1138
1149
let oneDayDuration : number = HoursInADay ;
1139
1150
let oneHourDuration : number = MinutesInAHour ;
@@ -1154,36 +1165,36 @@ module powerbi.extensibility.visual {
1154
1165
1155
1166
let label : string = "" ;
1156
1167
const days : number = Math . floor ( duration / oneDayDuration ) ;
1157
- label += days ? `${ days } Days ` : `` ;
1168
+ label += days ? `${ days } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Days" ) } ` : `` ;
1158
1169
if ( durationUnit === DurationUnits . Day ) {
1159
- return `${ duration } Days ` ;
1170
+ return `${ duration } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Days" ) } ` ;
1160
1171
}
1161
1172
1162
1173
let timeDelta : number = days * oneDayDuration ;
1163
1174
const hours : number = Math . floor ( ( duration - timeDelta ) / oneHourDuration ) ;
1164
- label += hours ? `${ hours } Hours ` : `` ;
1175
+ label += hours ? `${ hours } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Hours" ) } ` : `` ;
1165
1176
if ( durationUnit === DurationUnits . Hour ) {
1166
1177
return duration >= 24
1167
1178
? label
1168
- : `${ duration } Hours ` ;
1179
+ : `${ duration } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Hours" ) } ` ;
1169
1180
}
1170
1181
1171
1182
timeDelta = ( days * oneDayDuration ) + ( hours * oneHourDuration ) ;
1172
1183
const minutes : number = Math . floor ( ( duration - timeDelta ) / oneMinuteDuration ) ;
1173
- label += minutes ? `${ minutes } Minutes ` : `` ;
1184
+ label += minutes ? `${ minutes } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Minutes" ) } ` : `` ;
1174
1185
if ( durationUnit === DurationUnits . Minute ) {
1175
1186
return duration >= 60
1176
1187
? label
1177
- : `${ duration } Minutes ` ;
1188
+ : `${ duration } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Minutes" ) } ` ;
1178
1189
}
1179
1190
1180
1191
timeDelta = ( days * oneDayDuration ) + ( hours * oneHourDuration ) + ( minutes * oneMinuteDuration ) ;
1181
1192
const seconds : number = Math . floor ( duration - timeDelta ) ;
1182
- label += seconds ? `${ seconds } Seconds ` : `` ;
1193
+ label += seconds ? `${ seconds } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Seconds" ) } ` : `` ;
1183
1194
if ( durationUnit === DurationUnits . Second ) {
1184
1195
return duration >= 60
1185
1196
? label
1186
- : `${ duration } Seconds ` ;
1197
+ : `${ duration } ${ localizationManager . getDisplayName ( "Visual_DurationUnit_Seconds" ) } ` ;
1187
1198
}
1188
1199
}
1189
1200
@@ -1196,7 +1207,8 @@ module powerbi.extensibility.visual {
1196
1207
public static converter (
1197
1208
dataView : DataView ,
1198
1209
host : IVisualHost ,
1199
- colors : IColorPalette ) : GanttViewModel {
1210
+ colors : IColorPalette ,
1211
+ localizationManager : ILocalizationManager ) : GanttViewModel {
1200
1212
1201
1213
if ( ! dataView
1202
1214
|| ! dataView . categorical
@@ -1221,7 +1233,7 @@ module powerbi.extensibility.visual {
1221
1233
? settings . taskConfig . fill
1222
1234
: null ;
1223
1235
1224
- const tasks : Task [ ] = Gantt . createTasks ( dataView , taskTypes , host , formatters , colors , settings , taskColor ) ;
1236
+ const tasks : Task [ ] = Gantt . createTasks ( dataView , taskTypes , host , formatters , colors , settings , taskColor , localizationManager ) ;
1225
1237
1226
1238
// Remove empty legend if tasks isn't exist
1227
1239
const types = _ . groupBy ( tasks , x => x . taskType ) ;
@@ -1349,7 +1361,7 @@ module powerbi.extensibility.visual {
1349
1361
return ;
1350
1362
}
1351
1363
1352
- this . viewModel = Gantt . converter ( options . dataViews [ 0 ] , this . host , this . colors ) ;
1364
+ this . viewModel = Gantt . converter ( options . dataViews [ 0 ] , this . host , this . colors , this . localizationManager ) ;
1353
1365
if ( ! this . viewModel || ! this . viewModel . tasks || this . viewModel . tasks . length <= 0 ) {
1354
1366
this . clearViewport ( ) ;
1355
1367
return ;
@@ -1473,7 +1485,7 @@ module powerbi.extensibility.visual {
1473
1485
1474
1486
let dataTypeDatetime : ValueType = ValueType . fromPrimitiveTypeAndCategory ( PrimitiveType . Date ) ;
1475
1487
let category : DataViewMetadataColumn = {
1476
- displayName : "Start Date" ,
1488
+ displayName : this . localizationManager . getDisplayName ( "Role_StartDate" ) ,
1477
1489
queryName : GanttRoles . StartDate ,
1478
1490
type : dataTypeDatetime ,
1479
1491
index : 0
@@ -2153,11 +2165,11 @@ module powerbi.extensibility.visual {
2153
2165
case DateTypes . Second :
2154
2166
case DateTypes . Minute :
2155
2167
case DateTypes . Hour :
2156
- milestoneTitle = LabelsForDateTypes . Now ;
2168
+ milestoneTitle = this . localizationManager . getDisplayName ( "Visual_Label_Now" ) ;
2157
2169
dateTime = new Date ( timestamp ) . toLocaleString ( ) ;
2158
2170
break ;
2159
2171
default :
2160
- milestoneTitle = LabelsForDateTypes . Today ;
2172
+ milestoneTitle = this . localizationManager . getDisplayName ( "Visual_Label_Today" ) ;
2161
2173
}
2162
2174
}
2163
2175
0 commit comments