@@ -23,7 +23,7 @@ const routeGroup = L.layerGroup().addTo(map);
2323
2424/************************************ Time line constants and variable definitions ************************************/
2525
26- const byVehiclePanel = document . getElementById ( "byVehiclePanel " ) ;
26+ const byVehicleTimelineElement = document . getElementById ( "byVehicleTimeline " ) ;
2727const byVehicleTimelineOptions = {
2828 timeAxis : { scale : "hour" } ,
2929 orientation : { axis : "top" } ,
@@ -35,9 +35,9 @@ const byVehicleTimelineOptions = {
3535} ;
3636const byVehicleGroupData = new vis . DataSet ( ) ;
3737const byVehicleItemData = new vis . DataSet ( ) ;
38- const byVehicleTimeline = new vis . Timeline ( byVehiclePanel , byVehicleItemData , byVehicleGroupData , byVehicleTimelineOptions ) ;
38+ const byVehicleTimeline = new vis . Timeline ( byVehicleTimelineElement , byVehicleItemData , byVehicleGroupData , byVehicleTimelineOptions ) ;
3939
40- const byVisitPanel = document . getElementById ( "byVisitPanel " ) ;
40+ const byVisitTimelineElement = document . getElementById ( "byVisitTimeline " ) ;
4141const byVisitTimelineOptions = {
4242 timeAxis : { scale : "hour" } ,
4343 orientation : { axis : "top" } ,
@@ -50,7 +50,7 @@ const byVisitTimelineOptions = {
5050} ;
5151const byVisitGroupData = new vis . DataSet ( ) ;
5252const byVisitItemData = new vis . DataSet ( ) ;
53- const byVisitTimeline = new vis . Timeline ( byVisitPanel , byVisitItemData , byVisitGroupData , byVisitTimelineOptions ) ;
53+ const byVisitTimeline = new vis . Timeline ( byVisitTimelineElement , byVisitItemData , byVisitGroupData , byVisitTimelineOptions ) ;
5454
5555const BG_COLORS = [ "#009E73" , "#0072B2" , "#D55E00" , "#000000" , "#CC79A7" , "#E69F00" , "#F0E442" , "#F6768E" , "#C10020" , "#A6BDD7" , "#803E75" , "#007D34" , "#56B4E9" , "#999999" , "#8DD3C7" , "#FFD92F" , "#B3DE69" , "#FB8072" , "#80B1D3" , "#B15928" , "#CAB2D6" , "#1B9E77" , "#E7298A" , "#6A3D9A" ] ;
5656const FG_COLORS = [ "#FFFFFF" , "#FFFFFF" , "#FFFFFF" , "#FFFFFF" , "#FFFFFF" , "#000000" , "#000000" , "#FFFFFF" , "#FFFFFF" , "#000000" , "#FFFFFF" , "#FFFFFF" , "#FFFFFF" , "#000000" , "#000000" , "#000000" , "#000000" , "#FFFFFF" , "#000000" , "#FFFFFF" , "#000000" , "#FFFFFF" , "#FFFFFF" , "#FFFFFF" ] ;
@@ -107,6 +107,11 @@ function colorByVehicle(vehicle) {
107107 return vehicle === null ? null : pickColor ( 'vehicle' + vehicle . id ) ;
108108}
109109
110+ function formatScore ( score ) {
111+ if ( ! score ) return '?' ;
112+ return score . replace ( 'hard' , 'H' ) . replace ( 'medium' , 'M' ) . replace ( 'soft' , 'S' ) ;
113+ }
114+
110115function formatDrivingTime ( drivingTimeInSeconds ) {
111116 return `${ Math . floor ( drivingTimeInSeconds / 3600 ) } h ${ Math . round ( ( drivingTimeInSeconds % 3600 ) / 60 ) } m` ;
112117}
@@ -209,7 +214,7 @@ function renderRoutes(solution) {
209214 }
210215
211216 // Summary
212- $ ( '#score' ) . text ( solution . score ) ;
217+ $ ( '#score' ) . text ( formatScore ( solution . score ) ) ;
213218 $ ( "#info" ) . text ( `This dataset has ${ solution . visits . length } visits who need to be assigned to ${ solution . vehicles . length } vehicles.` ) ;
214219 $ ( '#drivingTime' ) . text ( formatDrivingTime ( solution . totalDrivingTimeSeconds ) ) ;
215220}
@@ -303,7 +308,7 @@ function renderTimelines(routePlan) {
303308 id : visit . id + '_wait' ,
304309 group : visit . vehicle , // visit.vehicle is the vehicle.id due to Jackson serialization
305310 subgroup : visit . vehicle ,
306- content : byVehicleWaitElement . ahtml ( ) ,
311+ content : byVehicleWaitElement . html ( ) ,
307312 start : visit . arrivalTime ,
308313 end : visit . minStartTime
309314 } ) ;
@@ -353,6 +358,10 @@ function renderTimelines(routePlan) {
353358 byVehicleTimeline . setWindow ( routePlan . startDateTime , routePlan . endDateTime ) ;
354359 byVisitTimeline . setWindow ( routePlan . startDateTime , routePlan . endDateTime ) ;
355360 }
361+ requestAnimationFrame ( ( ) => {
362+ if ( $ ( '#byVehiclePanel' ) . hasClass ( 'active' ) ) byVehicleTimeline . redraw ( ) ;
363+ if ( $ ( '#byVisitPanel' ) . hasClass ( 'active' ) ) byVisitTimeline . redraw ( ) ;
364+ } ) ;
356365}
357366
358367function analyze ( ) {
0 commit comments