Event Markers

An event marker is a flag anchored to a point in time, drawn along the x-axis with a hover card. It answers "what happened here", which is a different question from the price annotations and drawings that answer "look at this level".

chart.addEventMarker({ x: '2024-02-01', type: 'earnings', label: 'Q4 FY24 beat' })
chart.addEventMarker({ x: '2024-03-15', type: 'dividend', label: '$0.24 per share' })
MethodDoes
addEventMarker(config)Adds one, returns its id
updateEventMarker(id, patch)Patches one
removeEventMarker(id)Removes one
clearEventMarkers()Removes all
getEventMarker(id) / getEventMarkers()Reads them back

Config

KeyTypeWhat it is
xtimestamp, Date, or categoryWhere on the axis. Required
type'earnings' | 'dividend' | 'split' | 'news' | 'custom'Defaults to 'custom'. Each type carries a default glyph and color
labelstringThe hover card's title
colorstringOverrides the type's color
glyphstringOverrides the badge text, one to three characters
position'bottom' | 'top'Defaults to 'bottom'
metaobjectAnything of yours, carried through events

The four named types exist so the common cases need no styling decision. custom plus a glyph and a color covers everything else.

How they are drawn

Markers live on a lightweight HTML overlay rather than in the chart's SVG. The overlay reprojects through zoom and pan, and markers scrolled outside the visible range are hidden rather than clamped to the edge, so a flag never claims a date it is not on.

Events

chart.on('eventMarkerHover', ({ id, marker, nativeEvent }) => {})
chart.on('eventMarkerClick', ({ id, marker, nativeEvent }) => {})

chart.on('eventMarkerAdded', ({ id, marker }) => {})
chart.on('eventMarkerUpdated', ({ id, marker }) => {})
chart.on('eventMarkerRemoved', ({ id }) => {})
chart.on('eventMarkersCleared', () => {})

eventMarkerClick with meta is the hook for opening a filing, a news item, or your own detail panel:

chart.addEventMarker({ x: '2024-02-01', type: 'news', label: 'Guidance raised', meta: { url: '/news/1284' } })
chart.on('eventMarkerClick', ({ marker }) => {
  if (marker.meta?.url) window.location.href = marker.meta.url
})

Persistence

Markers are captured by getState() and restored by setState(), meta included.

Not annotations, and not drawings

Three overlay systems, and picking the wrong one usually shows:

Event markersAnnotationsDrawings
Anchored toA timeA price, a time, or a band of eitherTwo points in price and time
DrawnOn the x-axis stripIn the plotIn the plot
Made byYour codeYour codeThe user, or your code
For"This happened on this date""This level matters"Technical analysis

See also