Class Timeline

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Div
com.vaadin.componentfactory.timeline.Timeline
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasOrderedComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasText, Serializable

@NpmPackage(value="vis-timeline",version="7.4.9") @NpmPackage(value="moment",version="2.29.1") @JsModule("./src/arrow.js") @JsModule("./src/vcf-timeline.js") @CssImport("vis-timeline/styles/vis-timeline-graph2d.min.css") @CssImport("./styles/timeline.css") public class Timeline extends com.vaadin.flow.component.html.Div
Timeline component definition. Timeline uses vis-timeline component to display data in time (see more at https://github.com/visjs/vis-timeline).
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText

    com.vaadin.flow.component.HasText.WhiteSpace
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Timeline(List<Item> items)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addItem(Item item)
    Add a new item to the timeline.
    void
    addItemRemoveListener(com.vaadin.flow.component.ComponentEventListener<ItemRemoveEvent> listener)
    Adds a listener for ItemRemoveEvent to the component.
    void
    addItemResizeListener(com.vaadin.flow.component.ComponentEventListener<ItemResizeEvent> listener)
    Adds a listener for ItemResizeEvent to the component.
    void
    addItemsDragAndDropListener(com.vaadin.flow.component.ComponentEventListener<ItemsDragAndDropEvent> listener)
    Adds a listener for ItemsDragAndDropEvent to the component.
    void
    fireItemRemoveEvent(String itemId, boolean fromClient)
    protected void
    fireItemResizeEvent(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient)
    Return the list of items that are currently part of the timeline.
    protected TimelineOptions
     
    protected void
    handleDragAndDrop(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient)
    Handle item moved by drag and drop.
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    void
    onMove(String itemId, String itemNewStart, String itemNewEnd, boolean resizedItem)
    Call from client when an item is moved (dragged and dropped or resized).
    void
    onRemove(String itemId)
    Call from client when an item is removed.
    void
    onSelect(String[] selectedItemsIds)
    Call from client when items are selected.
    void
    Removes an item.
    void
    setAutoZoom(boolean autoZoom)
    Sets whether all range should be visible at once.
    void
    Sets orientation of the timeline axis.
    void
    The initial end date for the axis of the timeline.
    void
    setHeight(String height)
    Sets the height of the timeline.
    void
    setItems(List<Item> items)
     
    void
    setMaxHeight(String maxHeight)
    Sets the maximum height for the timeline.
    void
    setMoveable(boolean moveable)
    Sets wheter the timeline can be moved by dragging the window.
    void
    setMultiselect(boolean multiselect)
    Sets whether multiple items can be selected.
    void
    setSelectable(boolean selectable)
    Sets wheter the items in the timeline can be selected.
    void
    setShowCurentTime(boolean showCurrentTime)
    Sets whether a vertical bar at current time is displayed.
    void
    setShowTooltips(boolean showTooltips)
    Sets whether tooltips will be displaying for items with defined titles.
    void
    Sets snap value.
    void
    setStack(boolean stack)
    Sets whether items will be stack on top of each other if they overlap.
    void
    Sets the initial start date for the axis of the timeline.
    void
    Sets visible range for timeline.
    void
    setTooltipOnItemUpdateTime(boolean tooltip)
    Sets whether tooltip should be displayed while updating an item.
    void
    Sets the date format for the dates displayed in the on update item tooltip.
    void
    Sets the template for the tooltip displayed on item update.
    void
    setZoomable(boolean zoomable)
    Sets whether the timeline can be zoomed by pinching or scrolling in the window.
    void
    setZoomOption(Integer zoomOption)
    Sets zoom option for timeline.
    void
    setZoomRange(Long zoomMin, Long zoomMax)
    Sets zoom range for timeline.
    void
    updateItemContent(String itemId, String newContent)
    Updates content of an existing item.

    Methods inherited from class com.vaadin.flow.component.HtmlComponent

    getTitle, setTitle

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replace

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasText

    bindText, getText, getWhiteSpace, setText, setWhiteSpace
  • Constructor Details

    • Timeline

      public Timeline()
    • Timeline

      public Timeline(List<Item> items)
  • Method Details

    • getTimelineOptions

      protected TimelineOptions getTimelineOptions()
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • addItem

      public void addItem(Item item)
      Add a new item to the timeline.
      Parameters:
      item - the new item to add to the timeline
    • setItems

      public void setItems(List<Item> items)
    • getItems

      public List<Item> getItems()
      Return the list of items that are currently part of the timeline.
      Returns:
      the list of items of the timeline
    • setTimelineRange

      public void setTimelineRange(LocalDateTime min, LocalDateTime max)
      Sets visible range for timeline.
      Parameters:
      min - minimum date
      max - maximum date
    • setAxisOrientation

      public void setAxisOrientation(AxisOrientation axisOrientation)
      Sets orientation of the timeline axis. By default axis is on top.
      Parameters:
      axisOrientation - orientation of the timeline axis
    • setZoomable

      public void setZoomable(boolean zoomable)
      Sets whether the timeline can be zoomed by pinching or scrolling in the window. By default, timeline is zoomable. Option moveable shoul be true.
      Parameters:
      zoomable - true if timeline is zoomable
    • setMoveable

      public void setMoveable(boolean moveable)
      Sets wheter the timeline can be moved by dragging the window. By default, timeline is moveable.
      Parameters:
      moveable - true if timeline is moveable
    • setZoomRange

      public void setZoomRange(Long zoomMin, Long zoomMax)
      Sets zoom range for timeline.
      Parameters:
      zoomMin - minimum zoom interval
      zoomMax - maximum zoom interval
    • setSelectable

      public void setSelectable(boolean selectable)
      Sets wheter the items in the timeline can be selected. By default, items are selectables.
      Parameters:
      selectable - true if times can be selected
    • setShowCurentTime

      public void setShowCurentTime(boolean showCurrentTime)
      Sets whether a vertical bar at current time is displayed. By default, not current time is displayed.
      Parameters:
      showCurrentTime - true if current time is shown
    • setHeight

      public void setHeight(String height)
      Sets the height of the timeline. Value can be in pixles or as percentaje (e.g. "300px"). When height is undefined or null, the height of the timeline is automatically adjusted to fit the contents.
    • setMaxHeight

      public void setMaxHeight(String maxHeight)
      Sets the maximum height for the timeline.
    • setStart

      public void setStart(LocalDateTime start)
      Sets the initial start date for the axis of the timeline. If it's not provided, the earliest date present in the events is taken as start date. If autoZoom is true, this option will be override.
      Parameters:
      start - initial start date
    • setAutoZoom

      public void setAutoZoom(boolean autoZoom)
      Sets whether all range should be visible at once. Only works if a range was defined by calling setTimelineRange(java.time.LocalDateTime, java.time.LocalDateTime). It will set start and end for timeline axis.
      Parameters:
      autoZoom - true if autozoom is allowed
    • setEnd

      public void setEnd(LocalDateTime end)
      The initial end date for the axis of the timeline. If not provided, the latest date present in the items set is taken as end date. If autoZoom is true, this option will be override.
      Parameters:
      end - initial end date
    • setStack

      public void setStack(boolean stack)
      Sets whether items will be stack on top of each other if they overlap. By default item will not stack.
      Parameters:
      stack - true if items should stack
    • setMultiselect

      public void setMultiselect(boolean multiselect)
      Sets whether multiple items can be selected. Option selectable should be true. By default, multiselect is disabled.
      Parameters:
      multiselect - true if multiselect is allowed
    • setShowTooltips

      public void setShowTooltips(boolean showTooltips)
      Sets whether tooltips will be displaying for items with defined titles. By default, tooltips will be visibles.
      Parameters:
      showTooltips - true if tooltips should be shown
    • updateItemContent

      public void updateItemContent(String itemId, String newContent)
      Updates content of an existing item.
      Parameters:
      itemId - id of item to be updated
      newContent - new item content
    • setSnapStep

      public void setSnapStep(SnapStep snapStep)
      Sets snap value. It can be an hour, half an hour or fifteen minutes. By default it is set at fifteeen minutes.
      Parameters:
      snapStep - snap value
    • setZoomOption

      public void setZoomOption(Integer zoomOption)
      Sets zoom option for timeline.
      Parameters:
      zoomOption - integer representing days for zooming
    • onMove

      @ClientCallable public void onMove(String itemId, String itemNewStart, String itemNewEnd, boolean resizedItem)
      Call from client when an item is moved (dragged and dropped or resized).
      Parameters:
      itemId - id of the moved item
      itemNewStart - new start date of the moved item
      itemNewEnd - new end date of the moved item
      resizedItem - true if item was resized
    • fireItemResizeEvent

      protected void fireItemResizeEvent(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient)
      Parameters:
      itemId - id of the item that was moved
      newStart - new start date for the item
      newEnd - new end date for the item
      fromClient - if event comes from client
    • handleDragAndDrop

      protected void handleDragAndDrop(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient)
      Handle item moved by drag and drop.
      Parameters:
      itemId - id of the item that was moved
      newStart - new start date for the item
      newEnd - new end date for the item
      fromClient - if event comes from client
    • addItemResizeListener

      public void addItemResizeListener(com.vaadin.flow.component.ComponentEventListener<ItemResizeEvent> listener)
      Adds a listener for ItemResizeEvent to the component.
      Parameters:
      listener - the listener to be added
    • removeItem

      public void removeItem(Item item)
      Removes an item.
      Parameters:
      item - item to be removed.
    • onRemove

      @ClientCallable public void onRemove(String itemId)
      Call from client when an item is removed.
      Parameters:
      itemId - id of the removed item
    • fireItemRemoveEvent

      public void fireItemRemoveEvent(String itemId, boolean fromClient)
      Parameters:
      itemId - id of the removed item
      fromClient - if event comes from client
    • addItemRemoveListener

      public void addItemRemoveListener(com.vaadin.flow.component.ComponentEventListener<ItemRemoveEvent> listener)
      Adds a listener for ItemRemoveEvent to the component.
      Parameters:
      listener - the listener to be added.
    • onSelect

      @ClientCallable public void onSelect(String[] selectedItemsIds)
      Call from client when items are selected.
      Parameters:
      selectedItemsIds - list of selected items
    • addItemsDragAndDropListener

      public void addItemsDragAndDropListener(com.vaadin.flow.component.ComponentEventListener<ItemsDragAndDropEvent> listener)
      Adds a listener for ItemsDragAndDropEvent to the component.
      Parameters:
      listener - the listener to be added
    • setTooltipOnItemUpdateTime

      public void setTooltipOnItemUpdateTime(boolean tooltip)
      Sets whether tooltip should be displayed while updating an item.
      Parameters:
      tooltip - true if tooltip is allowed
    • setTooltipOnItemUpdateTimeDateFormat

      public void setTooltipOnItemUpdateTimeDateFormat(String dateFormat)
      Sets the date format for the dates displayed in the on update item tooltip.
      Parameters:
      dateFormat - format for tooltip dates
    • setTooltipOnItemUpdateTimeTemplate

      public void setTooltipOnItemUpdateTimeTemplate(String template)
      Sets the template for the tooltip displayed on item update.

      To reference item start and end dates, please use item.start and item.end to be able to parse the template in the client-side.

      E.g.: Starting at item.start, ending at item.end.

      Parameters:
      template - the template shown in the tooltip