MCPcopy
hub / github.com/chartjs/Chart.js / createTooltipItem

Function createTooltipItem

src/plugins/plugin.tooltip.js:127–143  ·  view source on GitHub ↗

* Private helper to create a tooltip item model * @param {Chart} chart * @param {ActiveElement} item - {element, index, datasetIndex} to create the tooltip item for * @return new tooltip item

(chart, item)

Source from the content-addressed store, hash-verified

125 * @return new tooltip item
126 */
127function createTooltipItem(chart, item) {
128 const {element, datasetIndex, index} = item;
129 const controller = chart.getDatasetMeta(datasetIndex).controller;
130 const {label, value} = controller.getLabelAndValue(index);
131
132 return {
133 chart,
134 label,
135 parsed: controller.getParsed(index),
136 raw: chart.data.datasets[datasetIndex].data[index],
137 formattedValue: value,
138 dataset: controller.getDataset(),
139 dataIndex: index,
140 datasetIndex,
141 element
142 };
143}
144
145/**
146 * Get the size of the tooltip

Callers 1

_createItemsMethod · 0.85

Calls 4

getDatasetMetaMethod · 0.80
getParsedMethod · 0.80
getDatasetMethod · 0.80
getLabelAndValueMethod · 0.45

Tested by

no test coverage detected