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

Function createTooltipItem

src/plugins/plugin.tooltip.js:163–179  ·  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

161 * @return new tooltip item
162 */
163function createTooltipItem(chart, item) {
164 const {element, datasetIndex, index} = item;
165 const controller = chart.getDatasetMeta(datasetIndex).controller;
166 const {label, value} = controller.getLabelAndValue(index);
167
168 return {
169 chart,
170 label,
171 parsed: controller.getParsed(index),
172 raw: chart.data.datasets[datasetIndex].data[index],
173 formattedValue: value,
174 dataset: controller.getDataset(),
175 dataIndex: index,
176 datasetIndex,
177 element
178 };
179}
180
181/**
182 * 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