@@ -104,7 +104,12 @@ module powerbi.extensibility.visual {
104
104
const MillisecondsInWeek : number = 4 * MillisecondsInADay ;
105
105
const MillisecondsInAMonth : number = 30 * MillisecondsInADay ;
106
106
const MillisecondsInAYear : number = 365 * MillisecondsInADay ;
107
- const ChartLineHeight : number = 40 ;
107
+ function chartLineHeight ( lineHeight : number ) : number {
108
+ if ( ! lineHeight ) {
109
+ lineHeight = 40 ;
110
+ }
111
+ return lineHeight ;
112
+ } ;
108
113
const PaddingTasks : number = 5 ;
109
114
110
115
const GanttDurationUnitType = [
@@ -501,7 +506,7 @@ module powerbi.extensibility.visual {
501
506
} ;
502
507
}
503
508
504
- private static createLegend ( dataView : DataView , host : IVisualHost , colorPalette : IColorPalette , settings : GanttSettings , taskTypes : TaskTypes ) : LegendData {
509
+ private static createLegend ( host : IVisualHost , colorPalette : IColorPalette , settings : GanttSettings , taskTypes : TaskTypes ) : LegendData {
505
510
const colorHelper = new ColorHelper ( colorPalette , Gantt . LegendPropertyIdentifier ) ;
506
511
const legendData : LegendData = {
507
512
fontSize : settings . legend . fontSize ,
@@ -529,14 +534,14 @@ module powerbi.extensibility.visual {
529
534
* @param dataView The data Model.
530
535
* @param formatters task attributes represented format.
531
536
*/
532
-
533
537
private static createTasks (
534
538
dataView : DataView ,
535
539
taskTypes : TaskTypes ,
536
540
host : IVisualHost ,
537
541
formatters : GanttChartFormatters ,
538
542
colors : IColorPalette ,
539
- settings : GanttSettings
543
+ settings : GanttSettings ,
544
+ taskColor : string
540
545
) : Task [ ] {
541
546
const tasks : Task [ ] = [ ] ;
542
547
const colorHelper : ColorHelper = new ColorHelper (
@@ -553,7 +558,7 @@ module powerbi.extensibility.visual {
553
558
const selectoinBuider : ISelectionIdBuilder = host
554
559
. createSelectionIdBuilder ( )
555
560
. withCategory ( dataView . categorical . categories [ 0 ] , index ) ;
556
- let color = Gantt . DefaultValues . TaskColor ;
561
+ let color = taskColor || Gantt . DefaultValues . TaskColor ;
557
562
const taskType = _ . find ( taskTypes . types , ( typeMeta : TaskTypeMetadata ) => typeMeta . name === group . Duration . source . groupName ) ;
558
563
if ( taskType ) {
559
564
selectoinBuider
@@ -662,18 +667,22 @@ module powerbi.extensibility.visual {
662
667
return null ;
663
668
}
664
669
665
- const settings : GanttSettings = GanttSettings . parse < GanttSettings > ( dataView ) ;
666
-
667
- const taskTypes : TaskTypes = Gantt . getAllTasksTypes ( dataView )
670
+ const settings : GanttSettings = GanttSettings . parse < GanttSettings > ( dataView )
671
+ , taskTypes : TaskTypes = Gantt . getAllTasksTypes ( dataView )
668
672
, formatters : GanttChartFormatters = this . getFormatters ( dataView , host . locale || null )
669
- , tasks : Task [ ] = Gantt . createTasks ( dataView , taskTypes , host , formatters , colors , settings ) ;
673
+ , legendData = Gantt . createLegend ( host , colors , settings , taskTypes ) ;
674
+
675
+ let taskColor : string = ( legendData . dataPoints . length <= 1 )
676
+ ? settings . taskConfig . fill
677
+ : null ;
670
678
679
+ const tasks : Task [ ] = Gantt . createTasks ( dataView , taskTypes , host , formatters , colors , settings , taskColor ) ;
671
680
return {
672
681
dataView,
673
682
settings,
674
683
taskTypes,
675
684
tasks,
676
- legendData : Gantt . createLegend ( dataView , host , colors , settings , taskTypes ) ,
685
+ legendData
677
686
} ;
678
687
}
679
688
@@ -806,7 +815,7 @@ module powerbi.extensibility.visual {
806
815
let axisLength : number = ticks * Gantt . DefaultTicksLength ;
807
816
this . ganttSvg
808
817
. attr ( {
809
- height : PixelConverter . toString ( groupedTasks . length * ChartLineHeight + this . margin . top ) ,
818
+ height : PixelConverter . toString ( groupedTasks . length * chartLineHeight ( this . viewModel . settings . taskConfig . height ) + this . margin . top ) ,
810
819
width : PixelConverter . toString ( this . margin . left + this . viewModel . settings . taskLabels . width + axisLength + Gantt . DefaultValues . ResourceWidth )
811
820
} ) ;
812
821
let viewportIn : IViewport = {
@@ -954,10 +963,17 @@ module powerbi.extensibility.visual {
954
963
let xAxis : d3 . svg . Axis = xAxisProperties . axis ;
955
964
xAxis . orient ( "bottom" ) ;
956
965
966
+
957
967
this . axisGroup
958
968
. transition ( )
959
969
. duration ( duration )
960
970
. call ( xAxis ) ;
971
+
972
+ let axisColor : string = this . viewModel . settings . dateType . axisColor ;
973
+ let axisTextColor : string = this . viewModel . settings . dateType . axisTextColor ;
974
+ this . axisGroup . selectAll ( "path" ) . style ( "stroke" , axisColor ) ; // Line
975
+ this . axisGroup . selectAll ( ".tick line" ) . style ( "stroke" , axisColor ) ; // ticks
976
+ this . axisGroup . selectAll ( ".tick text" ) . style ( "stroke" , axisTextColor ) ; // text
961
977
}
962
978
963
979
/**
@@ -1032,9 +1048,9 @@ module powerbi.extensibility.visual {
1032
1048
. classed ( Selectors . TaskRect . class , true )
1033
1049
. attr ( {
1034
1050
x : ( task : Task ) => this . timeScale ( task . start ) ,
1035
- y : ( task : Task ) => Gantt . getBarYCoordinate ( task . id ) ,
1051
+ y : ( task : Task ) => Gantt . getBarYCoordinate ( task . id , this . viewModel . settings . taskConfig . height ) ,
1036
1052
width : ( task : Task ) => this . taskDurationToWidth ( task ) ,
1037
- height : ( ) => Gantt . getBarHeight ( )
1053
+ height : ( ) => Gantt . getBarHeight ( this . viewModel . settings . taskConfig . height )
1038
1054
} )
1039
1055
. style ( "fill" , ( task : Task ) => task . color ) ;
1040
1056
@@ -1051,7 +1067,7 @@ module powerbi.extensibility.visual {
1051
1067
taskProgress
1052
1068
. attr ( {
1053
1069
x : ( task : Task ) => this . timeScale ( task . start ) ,
1054
- y : ( task : Task ) => Gantt . getBarYCoordinate ( task . id ) + Gantt . getBarHeight ( ) / 2 - Gantt . DefaultValues . ProgressBarHeight / 2 ,
1070
+ y : ( task : Task ) => Gantt . getBarYCoordinate ( task . id , this . viewModel . settings . taskConfig . height ) + Gantt . getBarHeight ( this . viewModel . settings . taskConfig . height ) / 2 - Gantt . DefaultValues . ProgressBarHeight / 2 ,
1055
1071
width : ( task : Task ) => this . setTaskProgress ( task ) ,
1056
1072
height : Gantt . DefaultValues . ProgressBarHeight
1057
1073
} )
@@ -1074,7 +1090,7 @@ module powerbi.extensibility.visual {
1074
1090
taskResource
1075
1091
. attr ( {
1076
1092
x : ( task : Task ) => this . timeScale ( task . end ) + Gantt . TaskResourcePadding ,
1077
- y : ( task : Task ) => ( Gantt . getBarYCoordinate ( task . id ) + ( Gantt . getBarHeight ( ) / 2 ) + Gantt . TaskResourcePadding )
1093
+ y : ( task : Task ) => ( Gantt . getBarYCoordinate ( task . id , this . viewModel . settings . taskConfig . height ) + ( Gantt . getBarHeight ( this . viewModel . settings . taskConfig . height ) / 2 ) + Gantt . TaskResourcePadding )
1078
1094
} )
1079
1095
. text ( ( task : Task ) => task . resource )
1080
1096
. style ( {
@@ -1101,7 +1117,7 @@ module powerbi.extensibility.visual {
1101
1117
*/
1102
1118
private getTaskLabelCoordinateY ( taskIndex : number ) : number {
1103
1119
const fontSize : number = + this . viewModel . settings . taskLabels . fontSize ;
1104
- return ( ChartLineHeight * taskIndex ) + ( Gantt . getBarHeight ( ) + Gantt . BarHeightMargin - ( ChartLineHeight - fontSize ) / Gantt . ChartLineHeightDivider ) ;
1120
+ return ( chartLineHeight ( this . viewModel . settings . taskConfig . height ) * taskIndex ) + ( Gantt . getBarHeight ( this . viewModel . settings . taskConfig . height ) + Gantt . BarHeightMargin - ( chartLineHeight ( this . viewModel . settings . taskConfig . height ) - fontSize ) / Gantt . ChartLineHeightDivider ) ;
1105
1121
}
1106
1122
1107
1123
/**
@@ -1119,12 +1135,12 @@ module powerbi.extensibility.visual {
1119
1135
* Set the task progress bar in the gantt
1120
1136
* @param lineNumber Line number that represents the task number
1121
1137
*/
1122
- private static getBarYCoordinate ( lineNumber : number ) : number {
1123
- return ( ChartLineHeight * lineNumber ) + ( PaddingTasks ) ;
1138
+ private static getBarYCoordinate ( lineNumber : number , lineHeight : number ) : number {
1139
+ return ( lineHeight * lineNumber ) + ( PaddingTasks ) ;
1124
1140
}
1125
1141
1126
- private static getBarHeight ( ) : number {
1127
- return ChartLineHeight / Gantt . ChartLineProportion ;
1142
+ private static getBarHeight ( lineHeight : number ) : number {
1143
+ return lineHeight / Gantt . ChartLineProportion ;
1128
1144
}
1129
1145
1130
1146
/**
@@ -1147,6 +1163,7 @@ module powerbi.extensibility.visual {
1147
1163
* @param timestamp the milestone to be shown in the time axis (default Date.now())
1148
1164
*/
1149
1165
private createMilestoneLine ( tasks : GroupedTask [ ] , milestoneTitle : string = "Today" , timestamp : number = Date . now ( ) ) : void {
1166
+ let todayColor : string = this . viewModel . settings . dateType . todayColor ;
1150
1167
let line : Line [ ] = [ {
1151
1168
x1 : this . timeScale ( new Date ( timestamp ) ) ,
1152
1169
y1 : Gantt . MilestoneTop ,
@@ -1166,7 +1183,8 @@ module powerbi.extensibility.visual {
1166
1183
y1 : ( line : Line ) => line . y1 ,
1167
1184
x2 : ( line : Line ) => line . x2 ,
1168
1185
y2 : ( line : Line ) => line . y2
1169
- } ) ;
1186
+ } )
1187
+ . style ( "stroke" , todayColor ) ;
1170
1188
1171
1189
this . renderTooltip ( chartLineSelection ) ;
1172
1190
chartLineSelection . exit ( ) . remove ( ) ;
@@ -1188,7 +1206,7 @@ module powerbi.extensibility.visual {
1188
1206
}
1189
1207
1190
1208
private getMilestoneLineLength ( numOfTasks : number ) : number {
1191
- return numOfTasks * ChartLineHeight ;
1209
+ return numOfTasks * chartLineHeight ( this . viewModel . settings . taskConfig . height ) ;
1192
1210
}
1193
1211
1194
1212
public enumerateObjectInstances ( options : EnumerateVisualObjectInstancesOptions ) : VisualObjectInstanceEnumeration {
@@ -1222,6 +1240,7 @@ module powerbi.extensibility.visual {
1222
1240
} ) ;
1223
1241
} ) ;
1224
1242
}
1243
+
1225
1244
private addAnInstanceToEnumeration (
1226
1245
instanceEnumeration : VisualObjectInstanceEnumeration ,
1227
1246
instance : VisualObjectInstance ) : void {
0 commit comments