Timeline Documentation

The Timeline is the main HistropediaJS instance. Use it to render events, control viewport behaviour, configure zoom and pan, style the date scale, and access timeline-level methods.

Your First Timeline

With HistropediaJS loaded (see Installation), you're ready to render a timeline. Create a container element, instantiate the timeline, and load a few events.

HTML
<div id="timeline"></div>
JavaScript
import { Timeline } from 'histropediajs';

const container = document.getElementById('timeline');
const timeline = new Timeline(container, {
  width: 1000,
  height: 500,
  initialDate: { year: 1989, month: 3, day: 12 },
  zoom: { initial: 34 },
});

timeline.load([
  {
    id: 1,
    title: 'Moon Landing',
    subtitle: 'Apollo 11',
    from: { year: 1969, month: 7, day: 16 },
    to: { year: 1969, month: 7, day: 24 },
  },
  {
    id: 2,
    title: 'World Wide Web',
    subtitle: 'Tim Berners-Lee proposal',
    from: { year: 1989, month: 3, day: 12 },
  },
  {
    id: 3,
    title: 'iPhone Launch',
    subtitle: 'Apple unveils the iPhone',
    from: { year: 2007, month: 1, day: 9 },
  },
]);
🎉

Congratulations!

You've rendered your first interactive timeline. Head to the configuration and data model sections to customize it further.

Timeline Options

An object containing all settings supported by the timeline. Any option not specified will use the default value.

The timeline options are the main root for all configuration. They include nested settings for controlling zoom, panning, Lanes, Articles, Time Bands, Charts, image loading, and styling (shown below with links in the comments).

All timeline options, including nested options, can be set at timeline initialization by passing the object to the Timeline constructor. They can also be set at runtime using the setOption timeline method.

JavaScript
// Core timeline options (defaults)
{
  width: 1000,
  height: 500,
  verticalOffset: 40,
  enableUserControl: true,
  enableCursor: true,
  draggingVicinity: true,
  shiftBceDates: false,
  initialDate: {
    year: 1990,
    month: 1,
    day: 1,
  },
  bounds: { // new
    minDate: null,
    maxDate: null,
    overflow: 'elastic',
  },
  canvas: { // new
    dpr: 'auto',
    dprMode: 'stable',
    maxDpr: 3,
  },
  debugOverlays: { // new
    densityRegions: false,
  },
  zoom:     { /* See: Zoom Options */ },
  pan:      { /* See: Pan Options */ }, // new
  article:  { /* See: Article Options */ },
  lane:     { /* See: Lane Options */ }, // new
  timeBand: { /* See: Time Band Options */ }, // new
  chart:    { /* See: Chart Options */ },    // new
  image:    { /* See: Image Options */ },     // new
  style:    { /* See: Timeline Style */ },

  // Additional optional event handling:
  // - on: { 'event-name': (...args) => { /* handler */ } } // new

  //  deprecated Legacy event handlers (since v1.3.0):
  // - onRedraw
  // - onArticleClick
  // - onArticleDoubleClick
  // - onSave
}

Zoom Options

Control the zoom behavior of the timeline, including initial level, limits and wheel behaviour.

These options live under options.zoom.*. The values shown below are the defaults.

JavaScript
// Zoom options (defaults)
{
  initial: 34,
  minimum: 0,
  maximum: 123,
  wheelStep: 0.2, // changed default
  wheelSpeed: 3,
  allowCtrlWheel: false,    // new
  wheelMode: 'auto',        // new
  discreteWheelAnimation: { // new
    active: true,
    duration: 250
  },
  proportionalGain: 2,       // new
  proportionalExponent: 1.1, // new
  ratio: 0.8,
  unitSize: {
    initial: 200,
    showMinorLabels: 48,
    minimum: 8,
  }
};

Pan Options new

Control drag-release momentum after a user pans the timeline viewport.

These options live under options.pan.*. The values shown below are the defaults.

JavaScript
// Pan options (defaults)
{
  momentum: {
    active: true,
    sampleWindow: 100,
    minVelocity: 0.01,
    stopVelocity: 0.005,
    friction: 0.005,
    maxDuration: 5600
  }
};

Debugging and Logging new

HistropediaJS uses a centralized Logger service to control all debug output. Logging is disabled by default so it will not spam your console unless you explicitly turn it on.

You can toggle logging globally via the default Histropedia export, or work directly with the Logger class in ESM/bundler setups. UMD/script builds expose the same helpers on the global Histropedia namespace.

Enable or disable debug logging (default export helpers)

When using the default export, call the convenience helpers below to enable or disable debug output across the library. These methods internally delegate to the shared Logger instance.

JavaScript
import Histropedia from 'histropediajs';
// Or use the global Histropedia object directly for UMD/script-tag usage

// Turn on all HistropediaJS logging
Histropedia.enableDebug();

// Or explicitly set the flag
Histropedia.setDebug(true);

// Later, turn logging off again
Histropedia.disableDebug();
// Equivalent:
Histropedia.setDebug(false);

// Check current state
const isOn = Histropedia.isDebugEnabled(); // boolean

Using the Logger directly (ESM / bundlers)

In module-based builds you can import the Logger class directly. This gives you fine-grained control over the debug flag and lets you emit structured messages at different levels.

JavaScript
import { Logger } from 'histropediajs';

Logger.setEnabled(true); // enable logging
Logger.debug('Timeline initialized');
Logger.info('Loaded articles', articles);
Logger.warn('Something looks odd');
Logger.error('Something went wrong', err);

UMD / script-tag usage

When using the UMD build via a <script> tag, the same helpers are available on the global Histropedia object. You can either toggle logging via Histropedia.enableDebug() or work with Histropedia.Logger directly.

HTML
<script src="https://cdn.jsdelivr.net/npm/histropediajs@1/dist/histropedia.umd.min.js"></script>
<script>
  // Enable debug logging
  Histropedia.enableDebug();

  // Or via the Logger instance
  Histropedia.Logger.setEnabled(true);
  Histropedia.Logger.debug('Timeline ready');
</script>

Changing the debug label (console prefix)

All log messages are prefixed with a label (by default [Histropedia]) so you can easily spot them in the console. You can change this prefix to include your app name, environment, or any other marker.

JavaScript
import { Logger } from 'histropediajs';

// Set a custom label that will appear in front of every log message
Logger.setPrefix('[MyApp Timeline]');

Logger.setEnabled(true);
Logger.debug('Loading articles...');
// Output: [MyApp Timeline] Loading articles...

For script-tag/UMD usage you can configure the same prefix via the global Logger instance:

JavaScript
Histropedia.Logger.setPrefix('[MyApp Timeline]');
Histropedia.enableDebug();
Histropedia.Logger.info('Timeline is ready');
// Output: [MyApp Timeline] Timeline is ready

The prefix is applied to all standard console-style methods exposed by the logger (log, info, warn, error, debug, group, groupCollapsed, groupEnd).

Visual density-region guides new

Visual diagnostics are configured per timeline and are separate from the global logging helpers above. Enable debugOverlays.densityRegions to draw vertical guides at the boundaries currently used by article-density filtering. The overlay is disabled by default and does not intercept pointer input or alter timeline state.

JavaScript
const timeline = new Histropedia.Timeline(container, {
  debugOverlays: {
    densityRegions: true
  }
});

// Toggle the guides later without changing global logging
timeline.setOption('debugOverlays.densityRegions', false);

Timeline Style

Define the base styling for the timeline canvas. Override these defaults per instance as needed.

These options live under options.style.*. The values shown below are the defaults.

JavaScript
// Timeline style options (defaults)
{
  mainLine: {
    visible: true,
    size: 8
  },
  draggingHighlight: {
    visible: true,
    area: { up: 0, down: 'edge' }, // changed default new values
    color: 'rgba(237, 247, 255, 0.5)'
  },
  marker: {
    minor: {
      height: 12,
      color: '#6097f2',
      futureColor: '#ccc'
    },
    major: {
      height: 30,
      color: '#0c3a88',
      futureColor: '#ccc'
    }
  },
  dateLabel: {
    minor: {
      font: 'normal 10px Calibri',
      color: '#333',
      futureColor: '#ccc',
      textAlign: 'start',
      offset: {
        x: 4,
        y: 0
      },
      bceText: '',
      thousandsSeparator: ',',
      yearPrefixes: {
        ka: { label: 'ka', value: 1000, minDivision: 1000 },
        Ma: { label: 'Ma', value: 1e6, minDivision: 1e5 },
        Ga: { label: 'Ga', value: 1e9, minDivision: 1e8 }
      }
    },
    major: {
      font: 'normal 16px Calibri',
      color: '#000',
      futureColor: '#ccc',
      textAlign: 'start',
      offset: {
        x: 4,
        y: 0
      },
      bceText: ' ʙᴄᴇ',
      thousandsSeparator: ',',
      yearPrefixes: {
        ka: { label: 'ka', value: 1000, minDivision: 1e5 },
        Ma: { label: 'Ma', value: 1e6, minDivision: 1e6 },
        Ga: { label: 'Ga', value: 1e9, minDivision: 1e9 }
      }
    }
  },
  cursor: { // new
    timeline: {
      hover: 'default',
      dragging: 'e-resize'
    },
    clickable: 'pointer',
    article: {
      hoverDraggable: 'move',
      dragging: 'move'
    }
  }
};

Timeline Methods

Master these methods to control every aspect of your timeline:

.load(articles)

Data

Load the given array of articles on to the timeline.

Parameters

article ArticleData[]

Array of Article objects. Each entry follows the Article Schema.

Returns

void – Loads the articles in place and updates internal state.

This method is used to populate the timeline with articles. It can be called again at any time to add more articles, provided they have unique id properties.

const timeline = new Histropedia.Timeline(container);

// Load articles on to the timeline
timeline.load([
  {
    id: 1,
    title: 'Moon Landing',
    subtitle: 'Apollo 11',
    from: { year: 1969, month: 7, day: 16 },
    to: { year: 1969, month: 7, day: 24 }
  },
  {
    id: 2,
    title: 'World Wide Web',
    subtitle: 'Tim Berners-Lee proposal',
    from: { year: 1989, month: 3, day: 12 }
  }
]);

.loadLanes(lanes) new

Data

Add or update explicit lane definitions.

Parameters

lanes LaneData[]

Array of Lane objects. Each entry follows the Lane Schema.

Returns

void – Adds or updates lanes and redraws the timeline.

If a lane already exists implicitly because article data referenced its id, loadLanes upgrades it to an explicit lane.

timeline.loadLanes([
  {
    id: 'people',
    title: 'People',
    layout: { heightWeight: 2 },
    article: {
      defaultCardLayout: 'landscape',
      defaultStyle: { width: 220 }
    }
  },
  {
    id: 'projects',
    title: 'Projects'
  }
]);

.loadLaneArticles(laneId, articles) new

Data

Stamp a lane id onto a batch of articles and load them onto the timeline.

Parameters

laneId string | number

Lane identifier to assign to every article in the batch.

articles ArticleData[]

Article objects. Existing conflicting lane values are overwritten by laneId.

Returns

void – Loads the articles and redraws the timeline.

timeline.loadLaneArticles('projects', [
  {
    id: 'analytical-engine',
    title: 'Analytical Engine',
    from: { year: 1837 }
  },
  {
    id: 'difference-engine',
    title: 'Difference Engine',
    from: { year: 1822 }
  }
]);

.loadTimeBands(bands) new

Data

Load the given array of Time Bands on to the timeline.

Parameters

bands TimeBandData[]

Array of Time Band objects. Each entry follows the Time Band Schema.

Returns

void – Loads the bands in place and updates internal state.

This method is used to populate the timeline with Time Bands. It can be called again at any time to add more bands, provided they have unique id properties.

const timeline = new Histropedia.Timeline(container);

// Load bands on to the timeline
timeline.loadTimeBands([
  {
    id: 1,
    title: "18th Century",
    from: { year: 1800, precision: 'century' }
  },
  {
    id: 2,
    title: "Presidency of John F. Kennedy",
    from: { year: 1961, month: 1, day: 20 },
    to: { year: 1963, month: 1, day: 22 }
  },
  {
    id: 3,
    title: "Digital Age (1970s - present)",
    from: { year: 1970, precision: 'decade' },
    isToPresent: true
  }
]);

.setOption(option, value?)

Configuration

Set any timeline option, or retrieve its current value when called with a dot-notation path.

Parameters

option string | object

Either a full timeline options object, or a dot-notation string pointing at a specific option.

value any

New value for the option when using a string path. Omit to read the current value instead.

Returns

any – Current option value when reading via a string path without a value argument; otherwise void.

For large inspections it is more efficient to use the timeline.options object directly (e.g. timeline.options.style).

// set new width and height
timeline.setOption({ width: 700, height: 400 });

// set mainLine size
timeline.setOption('style.mainLine.size', 10);

// set default article subheader height and color
timeline.setOption('article.defaultStyle.subheader', { height: 20, color: '#EEE' });

// get current animation settings
const animSettings = timeline.setOption('article.animation');

.setSize(width, height) new

Configuration

Resize the timeline canvas and reflow article layout to the given dimensions (CSS pixels).

Parameters

width number

New canvas width in pixels.

height number

New canvas height in pixels.

Returns

void – Resizes the canvas and triggers any necessary redraw.

Useful when the container resizes after initialisation. Call it from your own resize logic or a ResizeObserver.

const container = document.getElementById('timeline');
const timeline = new Histropedia.Timeline(container);

// Keep the timeline sized with the container
const resize = () => {
  timeline.setSize(container.clientWidth, container.clientHeight);
};

window.addEventListener('resize', resize);
resize();

.on(event, handler) new

Events

Register a runtime event listener for timeline interactions and updates.

Parameters

event string

Name of the timeline event to listen for (e.g. 'article-select').

handler function

Callback invoked with the event payload and, when available, the original DOM event.

Returns

void – Attaches the listener without returning a value.

See the Events & Handlers reference for the complete list of events and payload signatures.

const onArticleSelect = (article) => {
  console.log('Selected article:', article.title);
};

timeline.on('article-select', onArticleSelect);

timeline.on('viewport-drag-start', (dragPayload, pointerEvent) => {
  console.log('Viewport drag started', dragPayload, pointerEvent);
  console.log(this); // Always the timeline instance for all handlers
});

.off(event, handler)

Events

Unregister a previously added event listener.

Parameters

event string

Event name that was originally passed to timeline.on.

handler function

The exact callback reference that was used when registering the listener.

Returns

void – Removes the listener and returns nothing.

const onZoom = ({ zoom }) => {
  console.log('Zoom level:', zoom);
};

timeline.on('zoom', onZoom);

// stop listening when the UI panel closes
timeline.off('zoom', onZoom);

.getArticleById(id)

Query

Retrieve the article currently loaded on the timeline with the matching identifier.

Parameters

id string | number

Unique article identifier, as provided in your timeline article data.

Returns

Article | undefined – The matching article object, or undefined when no article is found.

// get the article with id = 1
const article = timeline.getArticleById(1);

// check article data (see article options for structure)
console.log(article.data);

// call article methods
article.setOption('hidePeriodLine', true);

.removeArticleById(id)

Data

Remove the article with the matching identifier from the timeline.

Parameters

id string | number

Exact article identifier. Numeric and string ids such as 1 and '1' are distinct.

Returns

void – Removes the first exact match when present.

new Removing an article now emits one settled timeline-state-change notification, allowing persistence handlers to save the updated article list. No notification is emitted when the id is not found.

timeline.on('timeline-state-change', saveTimelineState);

timeline.removeArticleById('apollo-11');
timeline.requestRedraw();

.getActiveArticle()

Query

Return the article currently selected by the user in the timeline UI.

Returns

Article | null – The active article object, if one is selected.

// get the currently active article
const article = timeline.getActiveArticle();

// check article data
console.log(article?.data);

// call article methods when available
article?.setOption('hidePeriodLine', true);

.getLaneById(id) new

Query

Retrieve the lane currently loaded on the timeline with the matching identifier.

Parameters

id string | number

Lane identifier, as provided in options.lane.data, timeline.loadLanes, or article data.

Returns

Lane | undefined – The matching lane object, if one exists.

const peopleLane = timeline.getLaneById('people');

peopleLane?.setStyle('title.color', '#1e3a8a');
peopleLane?.hide();

.moveLaneToIndex(lane, index) and lane reorder helpers new

Ordering

Reorder lanes from the timeline instance. Public lane index 0 is nearest the shared axis.

Parameters

lane Lane | string | number

Lane instance or lane id to move.

index number

Target public index for moveLaneToIndex. Out-of-range values are clamped.

Returns

Lane – The lane that was moved.

Related helpers: moveLaneBefore, moveLaneAfter, moveLaneUp, and moveLaneDown.

timeline.moveLaneToIndex('people', 0);
timeline.moveLaneAfter('projects', 'people');
timeline.moveLaneUp('reference');
timeline.moveLaneDown('people');

.goToDateAnim(dmy, options?) deprecated

Navigation

Deprecated animated date navigation. Prefer setStartDate(date, { padding, animation }).

Parameters

dmy Histropedia.Dmy

Destination date (e.g. new Histropedia.Dmy(year, month, day)). The target date lands on the left edge by default.

options object

Optional animation settings:

  • duration number – Animation length in milliseconds (default 2000).
  • easing string – Easing name (default 'swing'). Supported names: 'linear', 'swing', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic'.
  • offsetX number – Pixel offset to position the date within the viewport (default 0).
  • complete function – Callback invoked when the animation finishes.

Returns

void – Performs an animated pan without returning a value.

This method remains for compatibility and maps to timeline.setStartDate(dmy, { padding: offsetX, animation: { active: true, ... } }).

// create Dmy for 5th Jan 1970
const date = new Histropedia.Dmy(1970, 1, 5);

timeline.setStartDate(date, {
  padding: 50,
  animation: {
    active: true,
    duration: 400,
    complete: () => console.log('done!')
  }
});

.fitDateRange(start, end, options?) new

Navigation

Zoom and pan the viewport so a supplied date range fits inside the timeline width.

Parameters

start Dmy | DateParts

Start date as a Dmy instance or plain object such as { year: 1900 }.

end Dmy | DateParts

End date. Dates may be passed in either order.

options object

Optional fit settings:

  • padding number | { left?: number, right?: number } – Space in pixels between the fitted range and the viewport edge (default 0).
  • animation object – Optional animation settings: active, duration, and easing. Supported easing names: 'linear', 'swing', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic'.

Returns

void – Updates the viewport in place.

Year-only and month-only inputs are treated as full periods for fit calculations.

timeline.fitDateRange(
  { year: 1961, month: 1, day: 20 },
  { year: 1963, month: 11, day: 22 },
  {
    padding: { left: 80, right: 80 },
    animation: { active: true, duration: 500 }
  }
);

.fitArticleRange(article, options?) new

Navigation

Zoom and pan the viewport so a single article's full date range fits inside the timeline width.

Parameters

article Article

Article instance to fit, using its computed period.from and period.to dates.

options object

Optional fit settings:

  • padding number | { left?: number, right?: number } – Space in pixels between the fitted article range and the viewport edge (default 0).
  • animation object – Optional animation settings using the same shape as fitDateRange, including easing.

Returns

booleantrue when the article has a range that can be fitted; otherwise false.

The options object uses the same padding and animation keys as fitDateRange.

const article = timeline.getArticleById('apollo-11');

if (article) {
  timeline.fitArticleRange(article, {
    padding: 80,
    animation: { active: true, duration: 500 }
  });
}

.fitArticles(options?) new

Navigation

Zoom and pan the viewport so the currently unfiltered article cards fit inside the timeline width.

Parameters

options object

Optional fit settings:

  • padding number | { left?: number, right?: number } – Space in pixels between the outermost fitted article cards and the viewport edge (default 40).
  • articleFilter function – Optional predicate for choosing which articles to fit. By default, articles hidden by filters are excluded.
  • animation object – Optional animation settings using the same shape as fitDateRange, including easing.

Returns

booleantrue when at least one article can be fitted; otherwise false.

The fit uses each article's start date, card width, and connector offset rather than only the article date range.

// Fit all currently unfiltered articles
timeline.fitArticles();

// Fit only articles in a specific lane
timeline.fitArticles({
  padding: { left: 60, right: 60 },
  articleFilter: article => article.data.lane === 'projects',
  animation: { active: true, duration: 500 }
});

.goToPixelAnim(pixel, options?)

Navigation

Pan the timeline by a fixed number of pixels with smooth animation.

Parameters

pixel number

Pixels to move the timeline. Positive values go forward in time; negative values go backward.

options object

Optional animation settings:

  • duration number – Animation length in milliseconds (default 2000).
  • easing string – Easing name (default 'swing'). Supported names: 'linear', 'swing', 'easeInQuad', 'easeOutQuad', 'easeInOutQuad', 'easeInCubic', 'easeOutCubic', 'easeInOutCubic'.
  • complete function – Callback invoked when the animation finishes.

Returns

void – Performs an animated pan without returning a value.

// 50 pixels backward in time (viewport moves left)
timeline.goToPixelAnim(-50);

// 1 million pixels forward in time (viewport moves right)
timeline.goToPixelAnim(1e6);

// whole canvas width, useful for next/previous navigation arrows
timeline.goToPixelAnim(timeline.width);

// ... with all available options set
const options = {
    duration: 400,
    easing: 'linear',
    complete: () => console.log('done!')
};
timeline.goToPixelAnim(timeline.width, options);

.setStartDate(date, options?) new

Navigation

Set the viewport left edge to a date, optionally with left padding and animation.

Parameters

date string | Histropedia.Dmy | DateParts

Destination date as 'yyyy-mm-dd' (month/day optional), a Histropedia.Dmy instance, or a plain object such as { year: 1970 }. Missing month/day values default to 1.

options object

Optional settings:

  • padding number – Left padding in pixels for the supplied date (default 0).
  • animation object – Optional animation settings using active, duration, easing, and complete.

Returns

void – Updates the viewport start date in place.

The padding value applies only to the left edge. Plain date objects are copied before missing month/day values and optional shiftBceDates normalization are applied, so the caller's object is not mutated.

deprecated The legacy call setStartDate(date, pixelOffset) still treats the number as left padding, but logs a deprecation warning. Pass { padding: pixelOffset } instead.

// create Dmy for 5th Jan 1970
const date = new Histropedia.Dmy(1970, 1, 5);

// jump to date, with date located on left edge of canvas
timeline.setStartDate(date);

// ... with date located 80px from the left edge
timeline.setStartDate(date, { padding: 80 });

// ... with animation
timeline.setStartDate(date, {
  padding: 80,
  animation: { active: true, duration: 500 }
});

// set date using string notation
timeline.setStartDate('1970-6'); // 1st June 1970

// set BC date using string notation
timeline.setStartDate('-500-3-25'); // 25th March 500 BC

.setCentreDate(date, pixelOffset?)

Navigation

Position a date at the horizontal center of the viewport, with an optional pixel offset.

Parameters

date string | Histropedia.Dmy | DateParts

Destination date. Plain { year, month?, day? } objects are accepted; omitted month and day values default to 1.

pixelOffset number

Additional horizontal offset from the viewport center (default 0).

Returns

void – Updates the viewport start date in place.

timeline.setCentreDate({ year: 1969, month: 7, day: 20 });

// Position the date 40px to the right of center
timeline.setCentreDate({ year: 1969, month: 7, day: 20 }, 40);

.settleDateBounds(options?) new

Navigation

Move an out-of-range viewport back inside the currently configured date bounds.

Parameters

options object

Set animate to false to clamp immediately instead of using the default short settle animation.

Returns

booleantrue when a correction was applied; otherwise false.

Normal panning, momentum, wheel/pinch zoom, and programmatic navigation already respect options.bounds. Call this method after changing bounds at runtime when the existing viewport may lie outside the new range.

timeline.setOption({
  bounds: {
    minDate: { year: 1950 },
    maxDate: { year: 2010 },
    overflow: 'elastic'
  }
});

timeline.settleDateBounds({ animate: false });

.getZoom() new

Navigation

Retrieve the current zoom level applied to the timeline viewport.

Returns

number – Current zoom value (lower values are more zoomed in, higher values more zoomed out).

// read the current zoom
const currentZoom = timeline.getZoom();

// zoom out by a small amount
timeline.setZoom(currentZoom + 0.5);

// or, zoom in by a small amount
timeline.setZoom(currentZoom - 0.5);

.setZoom(zoom, centrePixel?)

Navigation

Apply a new zoom level while optionally specifying the point that stays anchored on screen.

Parameters

zoom number

Zoom level between 0 (most zoomed in) and 123 (most zoomed out). Values are clamped to timeline.options.zoom.minimum/maximum.

centrePixel number

Pixel position from the left edge that remains fixed during zoom. Defaults to half of the timeline width.

Returns

void – Updates the timeline zoom level in place.

// set zoom level 13.5, zooming from the centre of the canvas
timeline.setZoom(13.5);

// ... zooming from the left edge of the canvas
timeline.setZoom(13.5, 0);

// ... zooming from the right edge of the canvas
timeline.setZoom(13.5, timeline.width);

.requestRedraw(redrawFunction?)

Rendering

Queue a redraw so it runs at the optimal time, even while animations are in progress.

Parameters

redrawFunction function

Specific redraw function to run (timeline.redraw, timeline.repositionRedraw, timeline.defaultRedraw, or a custom function). Defaults to timeline.repositionRedraw.

Returns

void – Schedules the supplied redraw without returning a value.

Details

Use this after dynamic changes to avoid interrupting animations. Requests are coalesced with any in-flight animation work for a major performance boost.

// hide currently active article and set date labels to green
timeline.getActiveArticle().hiddenByFilter = true;
timeline.options.style.dateLabel.major.color = 'green';

// redraw the timeline using the default `repositionRedraw`
timeline.requestRedraw();

// specify the most basic redraw for extra performance
timeline.requestRedraw(timeline.redraw);

// or request a full restack of articles
timeline.requestRedraw(timeline.defaultRedraw);

.redraw()

Rendering

Run the fastest, most lightweight timeline redraw.

Returns

void – Applies the basic redraw immediately.

Details

Best used when the start date and zoom level are unchanged. Prefer requestRedraw to orchestrate redraw timing automatically.

// hide currently active article and set date labels to green
timeline.getActiveArticle().hiddenByFilter = true;
timeline.options.style.dateLabel.major.color = 'green';

// redraw to see the results
timeline.redraw();

// For best performance call via requestRedraw instead
timeline.requestRedraw(timeline.redraw);

.repositionRedraw()

Rendering

Redraw the timeline while recalculating article positions for new start dates or zoom levels.

Returns

void – Performs the repositioning redraw immediately.

Details

Calls all steps of .redraw and additionally re-computes article origins. Also the default function used by requestRedraw.

// hide currently active article and set date labels to green
timeline.getActiveArticle().hiddenByFilter = true;
timeline.options.style.dateLabel.major.color = 'green';

// redraw to see the changes
timeline.repositionRedraw();

// For best performance call via requestRedraw instead
timeline.requestRedraw(); // defaults to repositionRedraw

.defaultRedraw()

Rendering

Perform the most thorough timeline redraw, including article restacking.

Returns

void – Executes the full redraw immediately.

Details

Runs every step of .repositionRedraw and also re-stacks articles when options.article.autoStacking.active is enabled. Called automatically after user zoom or scroll actions.

// hide currently active article and set date labels to green
timeline.getActiveArticle().hiddenByFilter = true;
timeline.options.style.dateLabel.major.color = 'green';

// redraw to see the changes with restacked articles
timeline.defaultRedraw();

// For best performance call via requestRedraw instead
timeline.requestRedraw(timeline.defaultRedraw);

Need More Help?

If you can't find what you're looking for, browse the examples or contact us.