1.1.2 • Published 29 days ago

vue-timeline-chart v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
29 days ago

Features

  • Zooming
  • Infinite scrolling (using native horizontal scroll events, use shift+scroll to convert vertical to horizontal mouse scrolling)
  • Plotting ranges, points, markers and backgrounds
  • Adjustable timestamp labels per scale
  • Customizable

Usage

npm add vue-timeline-chart
import { Timeline } from 'vue-timeline-chart'
import 'vue-timeline-chart/style.css'

Example

<Timeline
  :groups="groups"
  :items="items"
  :markers="markers"
  :viewportMin="1691089380000"
  :viewportMax="1691101020000"
  :minViewportDuration="1000 * 60"
  :maxViewportDuration="1000 * 60 * 60 * 24 * 7"
  @mousemoveTimeline="onMousemoveTimeline"
  @mouseleaveTimeline="onMouseleaveTimeline"
>
  <template #group-label="{ group }">
    {{ group.content }}
  </template>

  <template #item="{item}">
    <div
      :title="item.title || null"
      style="inset: 0; position: absolute;"
    ></div>
  </template>
</Timeline>

Props

OptionTypeDefaultDescription
groupsTimelineGroup[][]Define (rows)
itemsTimelineItem[][]Items to display
markersTimelineMarker[][]Markers to display
viewportMinnumberundefinedMinimum timestamp of the viewport (prevents scrolling to before this point)
viewportMaxnumberundefinedMaximum timestamp of the viewport (prevents scrolling past this point)
minViewportDurationnumber60000 (1 min)Minimum duration of the viewport in ms (limits zooming in)
maxViewportDurationnumberundefinedMaximum duration of the viewport in ms (limits zooming out)
initialViewportStartnumberundefinedInitial start timestamp of the viewport
initialViewportEndnumberundefinedInitial end timestamp of the viewport
renderTimestampLabelfunction(timestamp: number, scale: { unit: string, step: number})undefinedCustom function to render timestamp labels
fixedLabelsbooleanfalseWhether to display group labels on top of the timeline
minTimestampWidthnumber100Minimum width a timestamp label should have in px (determines how many timestamps should be displayed)
maxZoomSpeednumber60Limits the wheel event's deltaY value to prevent zooming too fast
activeItemsTimelineItem['id'][][]IDs of items that should have an active class

Slots

SlotPropsDescription
timestamp{ timestamp: number, scale: { unit: string, step: number } }Timestamp label
group-label{ group: TimelineGroup }Group label
items-GROUPID{ group: TimelineGroup, itemsInViewport: TimelineItem[], viewportStart: number, viewportEnd: number }Slot for all items within a group, useful when rendering the items manually (e.g. when using a chart or canvas)
item{ item: TimelineItem }Item content

Events

EventArgumentsDescription
click{time: number, event: MouseEvent, item: TimelineItem \| null}Click event on the timeline
contextmenu{time: number, event: MouseEvent, item: TimelineItem \| null}Right-click event on the timeline
mousemoveTimeline{time: number, event: MouseEvent}Mousemove event on the timeline
mouseleaveTimeline{event: MouseEvent}Mouseleave event on the timeline
changeViewport{ start: number, end: number }Visible range has changed
changeScale{ unit: string, step: number }Visible scale (minutes/hours/days/etc.) has changed

The time argument is the position (in ms) in the timeline where the mouse is hovering.

TimelineGroup

TimelineGroups are the rows in the timeline with items.

OptionTypeDefaultDescription
idstring(required)Unique ID, to bind items to
contentstring(required)Group label
classNamestring''CSS class(es)

TimelineItem

TimelineItems can be points, ranges, backgrounds or markers. They are assigned to a group by their group property.

OptionTypeDefaultDescription
idstringundefinedUnique ID, to match with activeItems prop
startnumber(required)Timestamp
endnumber(required for range and background)Timestamp, only used for type range and background
classNamestring''CSS class(es)
typestring(required)Type of item, one of: point, range, background or marker
cssVariablesRecord<string, string>{}CSS variables to apply to the item (e.g. { '--height': '20%' })

TimelineMarker

To improve performance, you can add markers as an individual prop, instead of together with items. This allows you to update the position of a marker (e.g. to show the current time) while keeping the rest of the items cached.

OptionTypeDefaultDescription
idstringundefinedUnique ID, to match with activeItems prop
startnumber(required)Timestamp
classNamestring''CSS class(es)
typestring(required)marker

Development

Install dependencies:

pnpm install

Dev server with live reloading

pnpm start

Building the application and watching for changes

pnpm dev

Recommended IDE Setup

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.
1.1.2

29 days ago

1.1.1

1 month ago

1.1.0

3 months ago

1.0.0

4 months ago

0.7.1

4 months ago

0.7.0

4 months ago

0.6.1

5 months ago

0.5.0

6 months ago

0.4.1

7 months ago

0.6.0

6 months ago

0.4.0

8 months ago

0.3.0

8 months ago

0.2.7

8 months ago

0.2.6

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.2.3

9 months ago

0.2.2

9 months ago

0.2.1

9 months ago

0.2.0

9 months ago

0.1.0

9 months ago