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.
<div id="timeline"></div>
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 },
},
]);
const { Timeline } = Histropedia;
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: 'moon-landing',
title: 'Moon Landing',
subtitle: 'Apollo 11',
from: { year: 1969, month: 7, day: 16 },
to: { year: 1969, month: 7, day: 24 },
},
{
id: 'internet-created',
title: 'World Wide Web',
subtitle: 'Tim Berners-Lee proposal',
from: { year: 1989, month: 3, day: 12 },
},
{
id: 'iphone-launch',
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).
Every timeline option, including nested options, can be supplied when creating a timeline by passing the object
to the Timeline constructor. Most settings that affect an existing timeline can also be changed at
runtime using setOption().
// 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
}
year[-month[-day]][T| ]hour[:minute[:second[.SSS]]]. For example,
2026-08-13T12:30:15.250, -44-03-15 09:01, and
1000000000-06-15T12:00:00.001 are valid. Years may be negative or longer than four digits;
fractional seconds accept one to three digits and are right-padded. Omitted month/day values default to
1. Z, UTC offsets, named timezones, and more than three fractional digits are rejected;
these strings are not JavaScript Date instants. See
Dates and Dmy for the complete
shared date-value contract.
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.
// 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,
minimumMajor: 120 // new
}
};
ZOOM_DAY is 0, ZOOM_HOUR is -1,
ZOOM_MINUTE is -2, ZOOM_SECOND is -3, and
ZOOM_MILLISECOND is -4. These values identify the current date-scale unit; they are not
numeric zoom.minimum thresholds. Approximate thresholds such as -82 depend on the zoom
configuration.
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.
// Pan options (defaults)
{
momentum: {
active: true,
sampleWindow: 100,
minVelocity: 0.01,
stopVelocity: 0.005,
friction: 0.005,
maxDuration: 5600
}
};
Debugging and Logging
Console logging is controlled globally, while visual debug overlays are configured per timeline. See the Debugging and Logging guide for logging helpers, direct Logger usage, console prefixes, and visual-overlay examples.
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.
// Timeline style options (defaults)
{
mainLine: {
visible: true,
size: 8,
color: '#cdd2d8', // new
dateIndicators: { // new
visible: true,
shape: 'rectangle',
size: 4,
color: '#666',
opacity: 1,
hiddenStyle: { opacity: 0.25 },
activeStyle: { color: 'article', opacity: 1 }
}
},
draggingHighlight: {
visible: true,
area: { up: 0, down: 'edge' }, // changed default new values
color: 'rgba(237, 247, 255, 0.5)'
},
marker: {
minor: {
height: 12,
extend: false,
color: '#6097f2',
futureColor: '#ccc'
},
major: {
height: 30,
extend: false,
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
},
sticky: { // new
enabled: 'auto',
offsetX: 4
},
bceText: ' ʙᴄᴇ',
thousandsSeparator: ',',
yearPrefixes: {
ka: { label: 'ka', value: 1000, minDivision: 1e5 },
Ma: { label: 'Ma', value: 1e6, minDivision: 1e6 },
Ga: { label: 'Ga', value: 1e9, minDivision: 1e9 }
}
},
parent: { // new
visible: false,
levels: 'all',
height: 20,
font: 'normal 14px Calibri',
color: '#444',
futureColor: '#ccc',
textAlign: 'start',
offset: { x: 4, y: 0 },
sticky: { enabled: true, offsetX: 4 }
}
},
cursor: { // new
timeline: {
hover: 'default',
dragging: 'e-resize'
},
clickable: 'pointer',
article: {
hoverDraggable: 'move',
dragging: 'move'
}
}
};
zoom.unitSize.minimumMajor; significant minor subdivisions appear only when they meet
the minor-label threshold. Major labels keep the same time format at natural boundaries. Enable
dateLabel.parent.visible when you want a separate higher-level calendar context row.
Timeline Methods
Master these methods to control every aspect of your timeline:
DateValue inputs Date/time input
Navigation methods accept a date/time parts object, a Dmy instance, or a timezone-free
canonical Histropedia date string. See Dates
and Dmy for the string grammar, omitted-field defaults, BCE numbering, construction,
formatting, arithmetic, and comparison.
.getStatusForSave()
StateSerialize the current viewport and article state to the compact legacy JSON format.
Returns
string – JSON containing the viewport date, zoom, reposition window, title,
owner id, and compact article state.
Sub-day viewports add fhr (hour), fmi (minute), fs
(second), and fms (millisecond). Each field is omitted when its value is zero, so
day-level and midnight output stays compact and compatible with legacy saved state.
const saved = JSON.parse(timeline.getStatusForSave());
// At 12:30:15.250 the viewport fields include:
// { fy: 2026, fm: 8, fd: 13, fhr: 12, fmi: 30, fs: 15, fms: 250, ... }
.load(articles)
DataLoad the given array of articles on to the timeline.
Parameters
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
DataAdd or update explicit lane definitions.
Parameters
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
DataStamp 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
DataLoad the given array of Time Bands on to the timeline.
Parameters
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?)
ConfigurationSet timeline options at runtime using a dot-notation path or sparse object, or read a stored option path.
Parameters
option string | object
Either a sparse 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.
Most settings that affect an existing timeline can be changed at runtime using
setOption(). Notable exceptions are initialization settings such as
initialDate, zoom.initial, enableUserControl, constructor
event handlers, preloaded data, and image-loader configuration. Use the relevant runtime method
or create a new timeline instance for these settings.
- Viewport/date:
setStartDate(),setCentreDate(),setZoom(), andfitDateRange(). - Events:
on()andoff(). - Data: the relevant add or load methods.
- Interaction wiring and image-loader configuration: create a new timeline.
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
ConfigurationResize 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
EventsRegister 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)
EventsUnregister a previously added event listener.
Parameters
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)
QueryRetrieve 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)
DataRemove 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()
QueryReturn 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
QueryRetrieve 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
OrderingReorder 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
NavigationDeprecated animated date navigation. Prefer setStartDate(date, { padding, animation }).
Parameters
dmy DateValue
Destination as a date/time parts object, Dmy, or canonical Histropedia date/time
string. The target date lands on the left edge by default.
options object
Optional animation settings:
durationnumber – Animation length in milliseconds (default2000).easingstring – Easing name (default'swing'). Supported names:'linear','swing','easeInQuad','easeOutQuad','easeInOutQuad','easeInCubic','easeOutCubic','easeInOutCubic'.offsetXnumber – Pixel offset to position the date within the viewport (default0).completefunction – 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
NavigationZoom and pan the viewport so a supplied date range fits inside the timeline width.
Parameters
start DateValue
Start date as a date/time parts object, Dmy, or canonical Histropedia string.
end DateValue
End date in the same forms. Dates may be passed in either order.
options object
Optional fit settings:
paddingnumber | { left?: number, right?: number } – Space in pixels between the fitted range and the viewport edge (default0).animationobject – Optional animation settings:active,duration, andeasing. Supported easing names:'linear','swing','easeInQuad','easeOutQuad','easeInOutQuad','easeInCubic','easeOutCubic','easeInOutCubic'.
Returns
void – Updates the viewport in place.
Time-free year-only and month-only strings are treated as complete calendar periods. Any time-bearing input is an exact instant, including a one-millisecond deep-time range.
timeline.fitDateRange(
{ year: 1961, month: 1, day: 20 },
{ year: 1963, month: 11, day: 22 },
{
padding: { left: 80, right: 80 },
animation: { active: true, duration: 500 }
}
);
timeline.fitDateRange(
'1000000000-06-15T12:00:00.000',
'1000000000-06-15T12:00:00.001'
);
.fitArticleRange(article, options?) new
NavigationZoom 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:
paddingnumber | { left?: number, right?: number } – Space in pixels between the fitted article range and the viewport edge (default0).animationobject – Optional animation settings using the same shape asfitDateRange, includingeasing.
Returns
boolean – true 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
NavigationZoom and pan the viewport so the currently unfiltered article cards fit inside the timeline width.
Parameters
options object
Optional fit settings:
paddingnumber | { left?: number, right?: number } – Space in pixels between the outermost fitted article cards and the viewport edge (default40).articleFilterfunction – Optional predicate for choosing which articles to fit. By default, articles hidden by filters are excluded.animationobject – Optional animation settings using the same shape asfitDateRange, includingeasing.
Returns
boolean – true 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?)
NavigationPan 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:
durationnumber – Animation length in milliseconds (default2000).easingstring – Easing name (default'swing'). Supported names:'linear','swing','easeInQuad','easeOutQuad','easeInOutQuad','easeInCubic','easeOutCubic','easeInOutCubic'.completefunction – 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
NavigationSet the viewport left edge to a date, optionally with left padding and animation.
Parameters
date DateValue
Destination as a date/time parts object, Histropedia.Dmy, or canonical string.
Missing month/day values default to 1; omitted time fields default to 0.
options object
Optional settings:
paddingnumber – Left padding in pixels for the supplied date (default0).animationobject – Optional animation settings usingactive,duration,easing, andcomplete.
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 BCE date/time using string notation
timeline.setStartDate('-44-03-15 09:01');
// set an exact timestamp (fraction is right-padded to .250)
timeline.setStartDate('2026-08-13T12:30:15.25');
.setCentreDate(date, pixelOffset?)
NavigationPosition a date at the horizontal center of the viewport, with an optional pixel offset.
Parameters
date DateValue
Destination as a date/time parts object, Dmy, or canonical Histropedia date/time
string. Omitted month/day values default to 1 and omitted time fields to 0.
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);
timeline.setCentreDate('2026-08-13T12:30:15.250');
.settleDateBounds(options?) new
NavigationMove 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
boolean – true 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
NavigationRetrieve 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?)
NavigationApply 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?)
RenderingQueue 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()
RenderingRun 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()
RenderingRedraw 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()
RenderingPerform 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.