• Stars
    star
    527
  • Rank 84,091 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Timelines Chart

Timelines Chart

NPM package Build Size NPM Downloads

A parallel timelines layout (swimlanes) for representing state of time-series over time. Each timeline segment can be assigned a value on a color scale, either continuous (heatmap mode) or ordinal (for categorical representation). Time-series can be grouped into logical groups, represented as distinct sections. Allows for exploration using drag-to-zoom or a timeline brush.

Check out the examples:

Quick start

import TimelinesChart from 'timelines-chart';

or using a script tag

<script src="//unpkg.com/timelines-chart"></script>

then

const myChart = TimelinesChart();
myChart
  .data(<myData>)
  (<myDOMElement>);

API reference

Method Description Default
data([array]) Getter/setter for chart data (see below for syntax details). []
width([number]) Getter/setter for the chart width in px. <window width>
maxHeight([number]) Getter/setter for the chart's maximum height in px. 640
maxLineHeight([number]) Getter/setter for the maximum height of each line, in px. 12
leftMargin([number]) Getter/setter for the chart's left margin, which contains the left-side group axis labels. 90
rightMargin([number]) Getter/setter for the chart's right margin, which contains the right-side series axis labels. 100
topMargin([number]) Getter/setter for the chart's top margin, which contains the color legend. 26
bottomMargin([number]) Getter/setter for the chart's bottom margin, which contains the time axis labels. 30
useUtc([boolean]) Getter/setter for whether to display time in the local time zone (false) or in UTC (true). false
timeFormat([string]) Getter/setter for the time format to use in tooltips. See d3-time-format for available options. %Y-%m-%d %-I:%M:%S %p
xTickFormat([function]) X axis tick label formatter function, as pass-through to d3-axis. By default, it uses a multi-scale time format.
dateMarker([date object]) Getter/setter for the date marker to show as a vertical line. If a falsy value is used, no marker is shown. null
minSegmentDuration([number]) Getter/setter for the minimum time duration (in msecs) of a segment in order for it to be shown. 0
getNLines() Returns number of timelines currently visible in the chart. -
getTotalNLines() Returns total number of timelines in the chart. -
zQualitative([boolean]) Getter/setter for whether the segment data color values are categorical (true) or quantitative (false). This will affect how the color legend is presented, and changing it will automatically toggle the zColorScale between defaults. false
zColorScale([d3 scale object]) Getter/setter for the color scale to be used for coloring the segments according to their data values. This object should be a D3 color scale object. qualitative: d3.scaleOrdinal(<color-list>)
quantitative: d3.scaleSequential(<color-interpolator>)
zDataLabel([string]) Getter/setter for the units of z data. Used in the tooltip descriptions.
zScaleLabel([string]) Getter/setter for the color scale label. Only applicable to quantitative z scales.
sort([[function, function]]) Sorts the timelines and groups according to two name comparison functions: function(labelCmpFn, groupCompFn). Each comparison function should follow the signature function(nameA, nameB) and return a numeric value. (<alpha-numeric-cmp>, <alpha-numeric-cmp>)
sortAlpha([[boolean]]) Sorts the timelines and groups in alpha-numeric order. The boolean parameter indicates whether the order should be ascending (true) or descending (false). true
sortChrono([[boolean]]) Sorts the timelines and groups in chronological order of their most recent data point. The boolean parameter indicates whether the order should be ascending (true) or descending (false). true
zoomX([[startDate, endDate]]) Getter/setter for the chart's time (horizontal) zoom. A null value indicates a zoom reset to full extent. null
zoomY([[number, number]]) Getter/setter for the chart's vertical zoom. The parameter should follow the syntax [<start row index>, <end row index>]. A null value indicates a zoom reset to full extent. null
zoomYLabels([[number, number]]) Getter/setter for the chart's vertical zoom in terms of timeline labels. The parameter should follow the syntax [<start label>, <end label>]. A null value indicates a zoom reset to full extent. null
onZoom([function]) Getter/setter for the callback function for user initiated zoom (incl. zoom resets). Callback will have two parameters: onZoom([startDate, endDate], [startY, endY]). null
enableOverview([boolean]) Getter/setter for whether to show an interactive timeline overview below the chart. true
overviewDomain([[startDate, endDate]]) Getter/setter for the time extent shown in the overview section below the chart. <auto-derived from data: [minTs, maxTs]>
getVisibleStructure() Returns data representation of timelines currently visible in the chart. -
getSvg() Returns graphic (SVG) representation of currently visible chart. -
enableAnimations([boolean]) Getter/setter for whether to animate transitions. true
onLabelClick([function]) Getter/setter for the callback function for clicking on the Y axis labels. Callback will include the clicked label (if applicable) and group parameter: onLabelClick(<string>, <string>). null
onSegmentClick([function]) Getter/setter for the callback function for clicking on a segment. Callback will return a segment object: onSegmentClick(segment). null
segmentTooltipContent([function]) Getter/setter for the callback function to populate a custom tooltip for segments. The segment data point is provided as sole argument: segmentTooltipContent(d). Supports plain text or HTML content. null
refresh() Rerenders chart. -

Data syntax

[
  {
    group: "group1name",
    data: [
      {
        label: "label1name",
        data: [
          {
            timeRange: [<date>, <date>],
            val: <val: number (continuous dataScale) or string (ordinal dataScale)>
          },
          {
            timeRange: [<date>, <date>],
            val: <val>
          },
          ...
        ]
      },
      {
        label: "label2name",
        data: [...]
      },
      ...
    ],
  },
  {
    group: "group2name",
    data: [...]
  },
  ...
]

Giving Back

paypal If this project has helped you and you'd like to contribute back, you can always buy me a ☕!

More Repositories

1

3d-force-graph

3D force-directed graph component using ThreeJS/WebGL
HTML
4,252
star
2

react-force-graph

React component for 2D, 3D, VR and AR force directed graphs
HTML
1,861
star
3

globe.gl

UI component for Globe Data Visualization using ThreeJS/WebGL
HTML
1,809
star
4

force-graph

Force-directed graph rendered on HTML5 canvas
JavaScript
1,409
star
5

three-globe

WebGL Globe Data Visualization as a ThreeJS reusable 3D object
JavaScript
1,071
star
6

react-globe.gl

React component for Globe Data Visualization using ThreeJS/WebGL
HTML
775
star
7

three-spritetext

A sprite based text component for ThreeJS
JavaScript
306
star
8

sunburst-chart

A sunburst interactive chart web component for visualizing hierarchical data
JavaScript
273
star
9

three-forcegraph

Force-directed graph as a ThreeJS 3d object
JavaScript
219
star
10

3d-force-graph-vr

3D force-directed graph component in VR
HTML
208
star
11

d3-force-registry

A curated compilation of plugins and all-things related to d3-force
133
star
12

3d-force-graph-ar

3D force-directed graph component in AR
HTML
87
star
13

aframe-forcegraph-component

Force-directed graph component for A-Frame
JavaScript
77
star
14

three-fatline

A ThreeJS Line object with variable width
JavaScript
68
star
15

circlepack-chart

A circle packing interactive chart web component for visualizing hierarchical data
JavaScript
55
star
16

kapsule

Kapsule - A closure based Web Component library
JavaScript
54
star
17

treemap-chart

A treemap interactive chart web component for visualizing hierarchical data
JavaScript
54
star
18

three-geojson-geometry

ThreeJS geometry to stroke GeoJSON objects on a sphere
JavaScript
52
star
19

globe-ar

3D Globe data visualization component in AR
HTML
51
star
20

three-render-objects

Easy way to render ThreeJS objects with built-in interaction defaults
JavaScript
45
star
21

horizon-timeseries-chart

A chart to represent time-series data using multiple vertically layered horizon area plots
JavaScript
44
star
22

three-conic-polygon-geometry

ThreeJS geometry for drawing polygons on a sphere
JavaScript
36
star
23

canvas-color-tracker

A utility to track objects on a canvas by unique px color
HTML
34
star
24

icicle-chart

A partition / icicle interactive chart web component for visualizing hierarchical data
JavaScript
33
star
25

d3-geo-zoom

Zoom and pan D3 geo projections
JavaScript
30
star
26

aframe-globe-component

3D Globe data visualization component for A-Frame
JavaScript
30
star
27

d3-force-magnetic

A natural attraction/repulsion force type for the d3-force simulation engine
JavaScript
27
star
28

hilbert-chart

Hilbert space-filling curve chart
JavaScript
27
star
29

d3-radial-axis

A radial implementation of the D3 axis component
JavaScript
25
star
30

ip.js

A JS library for manipulating IP addresses, prefixes and ranges
JavaScript
23
star
31

d3-hilbert

D3 layout to visualize distance variables using a continuous Hilbert space-filling curve.
JavaScript
22
star
32

d3-force-surface

A multi-surface elastic collision force type for the d3-force simulation engine
JavaScript
21
star
33

cartogram-chart

A cartogram chart web component for visualizing geographical data by distorting a TopoJson topology
JavaScript
19
star
34

d3-force-bounce

An elastic collision force type for the d3-force simulation engine
JavaScript
16
star
35

d3-morton-order

D3 layout to visualize distance variables using a continuous Morton (Z-order) space-filling curve.
JavaScript
11
star
36

d3-force-cluster-3d

A clustering force type for the d3-force-3d simulation engine
JavaScript
10
star
37

d3-binarytree

One-dimensional recursive spatial subdivision.
JavaScript
9
star
38

d3-horizon

Horizon area chart D3 component
JavaScript
8
star
39

proportions-chart

A one-dimensional proportional chart web component for visualizing categorical data
JavaScript
8
star
40

d3-force-limit

A positioning hard limit force type for the d3-force simulation engine
JavaScript
8
star
41

react-kapsule

React wrapper for kapsule-style web components
JavaScript
8
star
42

index-array-by

A utility function to index arrays by any criteria
JavaScript
8
star
43

Intermap

Internet Interactive Map
JavaScript
7
star
44

multilateration

Locate points according to distributed beacon signals with consistent propagation speeds
JavaScript
6
star
45

d3-zoomable

Easy way to apply d3-zoom functionality to DOM elements
JavaScript
6
star
46

data-joint

Perform data joins with any type of JS objects
JavaScript
6
star
47

d3-force-pod

Component to automatically draw nodes/links in a D3 force simulation according to a set of forces
JavaScript
5
star
48

accessor-fn

A wrapper function for object accessor properties
JavaScript
5
star
49

svg-text-fit

SVG utility for fitting text inside a box by resizing or ellipsis
JavaScript
3
star
50

d3-color-legend

SVG color legends for continuous or discrete D3 scales
JavaScript
3
star
51

jerrypick

Pluck and omit properties from a JS object
JavaScript
3
star
52

d3-force-constant

A constant acceleration force type for the d3-force simulation engine
JavaScript
3
star
53

ui-module

Template repo for UI modules
JavaScript
2
star
54

three-trackballcontrols-web

A browser friendly wrapper of https://github.com/JonLim/three-trackballcontrols
JavaScript
2
star
55

svg-utils

Miscellaneous utility components for manipulating SVG
JavaScript
2
star
56

forcelayout3d-web

A browser friendly wrapper of https://github.com/anvaka/ngraph.forcelayout3d
JavaScript
1
star
57

js-module

Template repo for JS modules
JavaScript
1
star
58

ris-live-viz

A quick RIS live viz prototype
JavaScript
1
star
59

flatten

Recursively flatten nested arrays with arbitrary levels
JavaScript
1
star
60

scroll-zoom-clamp

Prevent page scrolling interference by zooming components
JavaScript
1
star