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 -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a new item to the timeline.voidaddItemRemoveListener(com.vaadin.flow.component.ComponentEventListener<ItemRemoveEvent> listener) Adds a listener forItemRemoveEventto the component.voidaddItemResizeListener(com.vaadin.flow.component.ComponentEventListener<ItemResizeEvent> listener) Adds a listener forItemResizeEventto the component.voidaddItemsDragAndDropListener(com.vaadin.flow.component.ComponentEventListener<ItemsDragAndDropEvent> listener) Adds a listener forItemsDragAndDropEventto the component.voidfireItemRemoveEvent(String itemId, boolean fromClient) Fires aItemRemoveEvent.protected voidfireItemResizeEvent(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient) Fires aItemResizeEvent.getItems()Return the list of items that are currently part of the timeline.protected TimelineOptionsprotected voidhandleDragAndDrop(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient) Handle item moved by drag and drop.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidCall from client when an item is moved (dragged and dropped or resized).voidCall from client when an item is removed.voidCall from client when items are selected.voidremoveItem(Item item) Removes an item.voidsetAutoZoom(boolean autoZoom) Sets whether all range should be visible at once.voidsetAxisOrientation(AxisOrientation axisOrientation) Sets orientation of the timeline axis.voidsetEnd(LocalDateTime end) The initial end date for the axis of the timeline.voidSets the height of the timeline.voidvoidsetMaxHeight(String maxHeight) Sets the maximum height for the timeline.voidsetMoveable(boolean moveable) Sets wheter the timeline can be moved by dragging the window.voidsetMultiselect(boolean multiselect) Sets whether multiple items can be selected.voidsetSelectable(boolean selectable) Sets wheter the items in the timeline can be selected.voidsetShowCurentTime(boolean showCurrentTime) Sets whether a vertical bar at current time is displayed.voidsetShowTooltips(boolean showTooltips) Sets whether tooltips will be displaying for items with defined titles.voidsetSnapStep(SnapStep snapStep) Sets snap value.voidsetStack(boolean stack) Sets whether items will be stack on top of each other if they overlap.voidsetStart(LocalDateTime start) Sets the initial start date for the axis of the timeline.voidsetTimelineRange(LocalDateTime min, LocalDateTime max) Sets visible range for timeline.voidsetTooltipOnItemUpdateTime(boolean tooltip) Sets whether tooltip should be displayed while updating an item.voidsetTooltipOnItemUpdateTimeDateFormat(String dateFormat) Sets the date format for the dates displayed in the on update item tooltip.voidsetTooltipOnItemUpdateTimeTemplate(String template) Sets the template for the tooltip displayed on item update.voidsetZoomable(boolean zoomable) Sets whether the timeline can be zoomed by pinching or scrolling in the window.voidsetZoomOption(Integer zoomOption) Sets zoom option for timeline.voidsetZoomRange(Long zoomMin, Long zoomMax) Sets zoom range for timeline.voidupdateItemContent(String itemId, String newContent) Updates content of an existing item.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods 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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
bindText, getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
Timeline
public Timeline() -
Timeline
-
-
Method Details
-
getTimelineOptions
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
addItem
Add a new item to the timeline.- Parameters:
item- the new item to add to the timeline
-
setItems
-
getItems
Return the list of items that are currently part of the timeline.- Returns:
- the list of items of the timeline
-
setTimelineRange
Sets visible range for timeline.- Parameters:
min- minimum datemax- maximum date
-
setAxisOrientation
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
Sets zoom range for timeline.- Parameters:
zoomMin- minimum zoom intervalzoomMax- 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
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
Sets the maximum height for the timeline. -
setStart
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 callingsetTimelineRange(java.time.LocalDateTime, java.time.LocalDateTime). It will set start and end for timeline axis.- Parameters:
autoZoom- true if autozoom is allowed
-
setEnd
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
Updates content of an existing item.- Parameters:
itemId- id of item to be updatednewContent- new item content
-
setSnapStep
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
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 itemitemNewStart- new start date of the moved itemitemNewEnd- new end date of the moved itemresizedItem- true if item was resized
-
fireItemResizeEvent
protected void fireItemResizeEvent(String itemId, LocalDateTime newStart, LocalDateTime newEnd, boolean fromClient) Fires aItemResizeEvent.- Parameters:
itemId- id of the item that was movednewStart- new start date for the itemnewEnd- new end date for the itemfromClient- 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 movednewStart- new start date for the itemnewEnd- new end date for the itemfromClient- if event comes from client
-
addItemResizeListener
public void addItemResizeListener(com.vaadin.flow.component.ComponentEventListener<ItemResizeEvent> listener) Adds a listener forItemResizeEventto the component.- Parameters:
listener- the listener to be added
-
removeItem
Removes an item.- Parameters:
item- item to be removed.
-
onRemove
Call from client when an item is removed.- Parameters:
itemId- id of the removed item
-
fireItemRemoveEvent
Fires aItemRemoveEvent.- Parameters:
itemId- id of the removed itemfromClient- if event comes from client
-
addItemRemoveListener
public void addItemRemoveListener(com.vaadin.flow.component.ComponentEventListener<ItemRemoveEvent> listener) Adds a listener forItemRemoveEventto the component.- Parameters:
listener- the listener to be added.
-
onSelect
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 forItemsDragAndDropEventto 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
Sets the date format for the dates displayed in the on update item tooltip.- Parameters:
dateFormat- format for tooltip dates
-
setTooltipOnItemUpdateTimeTemplate
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
-