Home Forums FlexGanttFX Synchronizing the zoom factor between two Gantts

  • Author
    Posts
  • gmoubarak
    Participant
    Post count: 9
    #13043 |

    Hi,

    I’m displaying two gantts: one showing the activity sequence per object and another showing the activities per resrouces.

    I need to keep the same zoom factor when switching between them.

    before moving to the other gantt I read the visibleStartTime and visibleEndTime values and then I set those values on the next gantt by calling showRange().

    The zoom is not adjusted according to the values read from the previous gantt.
    Is there any better way to keep both gantt synchronised?

  • Dirk Lemmermann
    Keymaster
    Post count: 64
    #13045 |

    If the two charts are showing at the same time then you need to add a bidirectional binding between the “millisPerPixel” and the “startTime”property of the two timeline models used by the two timelines of the two Gantt charts.

    
    TimelineModel model1 = gantt1.getTimeline().getModel();
    TimelineModel model2 = gantt2.getTimeline().getModel();
    
    Bindings.bindBidirectional(model1.millisPerPixelProperty(), model2.millisPerPixelProperty());
    Bindings.bindBidirectional(model1.startTimeProperty(), model2.startTimeProperty());
    

    If the two charts are shown one after the other then you can do this:

    
    TimelineModel model1 = gantt1.getTimeline().getModel();
    TimelineModel model2 = gantt2.getTimeline().getModel();
    
    model2.setMillisPerPixel(model1.getMillisPerPixel();
    model2.setStartTime(model1.getStartTime());
    

You must be logged in to reply to this topic.