MCPcopy Create free account
hub / github.com/chartjs/Chart.js / title

Function title

src/plugins/plugin.tooltip.js:364–380  ·  view source on GitHub ↗
(tooltipItems)

Source from the content-addressed store, hash-verified

362 // Args are: (tooltipItems, data)
363 beforeTitle: noop,
364 title(tooltipItems) {
365 if (tooltipItems.length > 0) {
366 const item = tooltipItems[0];
367 const labels = item.chart.data.labels;
368 const labelCount = labels ? labels.length : 0;
369
370 if (this && this.options && this.options.mode === 'dataset') {
371 return item.dataset.label || '';
372 } else if (item.label) {
373 return item.label;
374 } else if (labelCount > 0 && item.dataIndex < labelCount) {
375 return labels[item.dataIndex];
376 }
377 }
378
379 return '';
380 },
381 afterTitle: noop,
382
383 // Args are: (tooltipItems, data)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected