Tooltip
Every chart opens a tooltip on the mark under the pointer, or reached with the keyboard. The tooltip option changes it for every chart type.
Off
createChart(host, spec, { tooltip: false });The marks still answer onHover and onClick: show what is pointed at somewhere else on the page.
Your own lines
format receives the point and returns a line, or several: the first one is the title. Lines are written as text, never read as HTML.
createChart(host, spec, {
tooltip: {
format: (p) => [p.label, `${p.series}: ${p.value} orders`],
},
});title and rows of the point hold what the tooltip writes by default, to build on it.
HTML
html returns HTML that is used as it is: escape every value that comes from data with the escape function it receives. Scripts, frames and event attributes (onclick…) are removed anyway.
createChart(host, spec, {
tooltip: {
html: (p, escape) => `<strong>${escape(p.label)}</strong><br><small>${escape(String(p.value))} €</small>`,
},
});The tooltip is a div.nervure-tooltip: style what you put in it with CSS.
Place
position: auto (default: on the right of the pointer, on the left near the edge), top, bottom, left or right. The tooltip always stays inside the chart.
createChart(host, spec, { tooltip: { position: 'top' } });From code
const chart = createChart(host, spec);
chart.showTooltip('Visits', 3); // series name (or its place, 0, 1…) and index of the mark
chart.hideTooltip();
chart.setActive('Visits', 3); // rings the mark, as the keyboard does, until…
chart.setActive(null);For charts with one list of marks (pie, treemap, funnel…), any series name works: chart.showTooltip('', 2). The ring of setActive stays when the chart is drawn again. Neither calls onHover.
Scatter
The tooltip field of a scatter spec still writes its lines; the format or html of the option wins when both are given.