Chart.js: Tooltip callback label for pie chart

Created on 2 Jun 2016  路  1Comment  路  Source: chartjs/Chart.js

How can I get the value of the slice where I am hovering in a pie chart? In a line chart it is possible to do tooltipItem.yLabel, but I can not find a similar approach for pie charts.

support

Most helpful comment

@DanielGJohnsen I would do:

function label(tooltipItem, chartInstance) {
  var value = chartInstance.data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
}

>All comments

@DanielGJohnsen I would do:

function label(tooltipItem, chartInstance) {
  var value = chartInstance.data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
}
Was this page helpful?
0 / 5 - 0 ratings