@@ -1269,6 +1269,181 @@ def test_gantt_validate_colors(self):
12691269 index_col = 'Complete' ,
12701270 colors = ['#ffffff' ])
12711271
1272+
1273+ def test_gannt_groups_and_descriptions (self ):
1274+
1275+ # check if grouped gantt chart matches with expected output
1276+
1277+ df = [
1278+ dict (Task = 'Task A' , Description = 'Task A - 1' , Start = '2008-10-05' ,
1279+ Finish = '2009-04-15' , IndexCol = 'TA' ),
1280+ dict (Task = "Task B" , Description = 'Task B - 1' , Start = '2008-12-06' ,
1281+ Finish = '2009-03-15' , IndexCol = 'TB' ),
1282+ dict (Task = "Task C" , Description = 'Task C - 1' , Start = '2008-09-07' ,
1283+ Finish = '2009-03-15' , IndexCol = 'TC' ),
1284+ dict (Task = "Task C" , Description = 'Task C - 2' , Start = '2009-05-08' ,
1285+ Finish = '2009-04-15' , IndexCol = 'TC' ),
1286+ dict (Task = "Task A" , Description = 'Task A - 2' , Start = '2009-04-20' ,
1287+ Finish = '2009-05-30' , IndexCol = 'TA' )
1288+ ]
1289+
1290+ test_gantt_chart = tls .FigureFactory .create_gantt (
1291+ df , colors = dict (TA = 'rgb(220, 0, 0)' , TB = 'rgb(170, 14, 200)' ,
1292+ TC = (1 , 0.9 , 0.16 )), show_colorbar = True , index_col = 'IndexCol' ,
1293+ group_tasks = True
1294+ )
1295+
1296+ exp_gantt_chart = {
1297+ 'data' : [{'marker' : {'color' : 'white' },
1298+ 'name' : '' ,
1299+ 'text' : 'Task A - 1' ,
1300+ 'x' : ['2008-10-05' , '2009-04-15' ],
1301+ 'y' : [2 , 2 ]},
1302+ {'marker' : {'color' : 'white' },
1303+ 'name' : '' ,
1304+ 'text' : 'Task B - 1' ,
1305+ 'x' : ['2008-12-06' , '2009-03-15' ],
1306+ 'y' : [1 , 1 ]},
1307+ {'marker' : {'color' : 'white' },
1308+ 'name' : '' ,
1309+ 'text' : 'Task C - 1' ,
1310+ 'x' : ['2008-09-07' , '2009-03-15' ],
1311+ 'y' : [0 , 0 ]},
1312+ {'marker' : {'color' : 'white' },
1313+ 'name' : '' ,
1314+ 'text' : 'Task C - 2' ,
1315+ 'x' : ['2009-05-08' , '2009-04-15' ],
1316+ 'y' : [0 , 0 ]},
1317+ {'marker' : {'color' : 'white' },
1318+ 'name' : '' ,
1319+ 'text' : 'Task A - 2' ,
1320+ 'x' : ['2009-04-20' , '2009-05-30' ],
1321+ 'y' : [2 , 2 ]},
1322+ {'hoverinfo' : 'none' ,
1323+ 'marker' : {'color' : 'rgb(220, 0, 0)' , 'size' : 1 },
1324+ 'name' : 'TA' ,
1325+ 'showlegend' : True ,
1326+ 'x' : ['2009-04-20' , '2009-04-20' ],
1327+ 'y' : [0 , 0 ]},
1328+ {'hoverinfo' : 'none' ,
1329+ 'marker' : {'color' : 'rgb(170, 14, 200)' , 'size' : 1 },
1330+ 'name' : 'TB' ,
1331+ 'showlegend' : True ,
1332+ 'x' : ['2009-04-20' , '2009-04-20' ],
1333+ 'y' : [1 , 1 ]},
1334+ {'hoverinfo' : 'none' ,
1335+ 'marker' : {'color' : 'rgb(255, 230, 41)' , 'size' : 1 },
1336+ 'name' : 'TC' ,
1337+ 'showlegend' : True ,
1338+ 'x' : ['2009-04-20' , '2009-04-20' ],
1339+ 'y' : [2 , 2 ]}],
1340+ 'layout' : {'height' : 600 ,
1341+ 'hovermode' : 'closest' ,
1342+ 'shapes' : [{'fillcolor' : 'rgb(220, 0, 0)' ,
1343+ 'line' : {'width' : 0 },
1344+ 'opacity' : 1 ,
1345+ 'type' : 'rect' ,
1346+ 'x0' : '2008-10-05' ,
1347+ 'x1' : '2009-04-15' ,
1348+ 'xref' : 'x' ,
1349+ 'y0' : 1.8 ,
1350+ 'y1' : 2.2 ,
1351+ 'yref' : 'y' },
1352+ {'fillcolor' : 'rgb(170, 14, 200)' ,
1353+ 'line' : {'width' : 0 },
1354+ 'opacity' : 1 ,
1355+ 'type' : 'rect' ,
1356+ 'x0' : '2008-12-06' ,
1357+ 'x1' : '2009-03-15' ,
1358+ 'xref' : 'x' ,
1359+ 'y0' : 0.8 ,
1360+ 'y1' : 1.2 ,
1361+ 'yref' : 'y' },
1362+ {'fillcolor' : 'rgb(255, 230, 41)' ,
1363+ 'line' : {'width' : 0 },
1364+ 'opacity' : 1 ,
1365+ 'type' : 'rect' ,
1366+ 'x0' : '2008-09-07' ,
1367+ 'x1' : '2009-03-15' ,
1368+ 'xref' : 'x' ,
1369+ 'y0' : - 0.2 ,
1370+ 'y1' : 0.2 ,
1371+ 'yref' : 'y' },
1372+ {'fillcolor' : 'rgb(255, 230, 41)' ,
1373+ 'line' : {'width' : 0 },
1374+ 'opacity' : 1 ,
1375+ 'type' : 'rect' ,
1376+ 'x0' : '2009-05-08' ,
1377+ 'x1' : '2009-04-15' ,
1378+ 'xref' : 'x' ,
1379+ 'y0' : - 0.2 ,
1380+ 'y1' : 0.2 ,
1381+ 'yref' : 'y' },
1382+ {'fillcolor' : 'rgb(220, 0, 0)' ,
1383+ 'line' : {'width' : 0 },
1384+ 'opacity' : 1 ,
1385+ 'type' : 'rect' ,
1386+ 'x0' : '2009-04-20' ,
1387+ 'x1' : '2009-05-30' ,
1388+ 'xref' : 'x' ,
1389+ 'y0' : 1.8 ,
1390+ 'y1' : 2.2 ,
1391+ 'yref' : 'y' }],
1392+ 'showlegend' : True ,
1393+ 'title' : 'Gantt Chart' ,
1394+ 'width' : 900 ,
1395+ 'xaxis' : {'rangeselector' : {'buttons' : [{'count' : 7 ,
1396+ 'label' : '1w' ,
1397+ 'step' : 'day' ,
1398+ 'stepmode' : 'backward' },
1399+ {'count' : 1 ,
1400+ 'label' : '1m' ,
1401+ 'step' : 'month' ,
1402+ 'stepmode' : 'backward' },
1403+ {'count' : 6 ,
1404+ 'label' : '6m' ,
1405+ 'step' : 'month' ,
1406+ 'stepmode' : 'backward' },
1407+ {'count' : 1 ,
1408+ 'label' : 'YTD' ,
1409+ 'step' : 'year' ,
1410+ 'stepmode' : 'todate' },
1411+ {'count' : 1 ,
1412+ 'label' : '1y' ,
1413+ 'step' : 'year' ,
1414+ 'stepmode' : 'backward' },
1415+ {'step' : 'all' }]},
1416+ 'showgrid' : False ,
1417+ 'type' : 'date' ,
1418+ 'zeroline' : False },
1419+ 'yaxis' : {'autorange' : False ,
1420+ 'range' : [- 1 , 4 ],
1421+ 'showgrid' : False ,
1422+ 'ticktext' : ['Task C' , 'Task B' , 'Task A' ],
1423+ 'tickvals' : [0 , 1 , 2 ],
1424+ 'zeroline' : False }}
1425+ }
1426+
1427+ self .assertEqual (test_gantt_chart ['data' ][0 ],
1428+ exp_gantt_chart ['data' ][0 ])
1429+
1430+ self .assertEqual (test_gantt_chart ['data' ][1 ],
1431+ exp_gantt_chart ['data' ][1 ])
1432+
1433+ self .assertEqual (test_gantt_chart ['data' ][2 ],
1434+ exp_gantt_chart ['data' ][2 ])
1435+
1436+ self .assertEqual (test_gantt_chart ['data' ][3 ],
1437+ exp_gantt_chart ['data' ][3 ])
1438+
1439+ self .assertEqual (test_gantt_chart ['data' ][4 ],
1440+ exp_gantt_chart ['data' ][4 ])
1441+
1442+ self .assertEqual (test_gantt_chart ['layout' ],
1443+ exp_gantt_chart ['layout' ])
1444+
1445+
1446+
12721447 def test_gantt_all_args (self ):
12731448
12741449 # check if gantt chart matches with expected output
0 commit comments