Skip to content

Commit

Permalink
fix(chartjs#11315): don't call getLabelAndValue on null controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-peteu committed Nov 9, 2023
1 parent b22e46c commit d35dc7f
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/plugins/plugin.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,29 @@ function splitNewlines(str) {
function createTooltipItem(chart, item) {
const {element, datasetIndex, index} = item;
const controller = chart.getDatasetMeta(datasetIndex).controller;
const {label, value} = controller.getLabelAndValue(index);

if (controller) {
const {label, value} = controller.getLabelAndValue(index);

return {
chart,
label,
parsed: controller.getParsed(index),
raw: chart.data.datasets[datasetIndex].data[index],
formattedValue: value,
dataset: controller.getDataset(),
dataIndex: index,
datasetIndex,
element
};
}

return {
chart,
label,
parsed: controller.getParsed(index),
raw: chart.data.datasets[datasetIndex].data[index],
formattedValue: value,
dataset: controller.getDataset(),
label: '',
parsed: undefined,
raw: undefined,
formattedValue: '',
dataIndex: index,
datasetIndex,
element
Expand Down

0 comments on commit d35dc7f

Please sign in to comment.