Is there way to show tooltip on radar char label?

๐Ÿ‘:0

I could set a custom interaction mode, as following:

Chart.Interaction.modes.labels = function(chart, e, options, useFinalPosition) {
  const result = [];
  const labels =  chart.data.labels;
  const datasets =  chart.data.datasets;
  for (let i = 0; i < labels.length; i++) {
    const area = chart.scales.r.getPointLabelPosition(i);
    if (e.x >= area.left && e.x <= area.right 
        && e.y >= area.top && e.y <= area.bottom) {
      for (let k = 0; k < datasets.length; k++) {
        const meta = chart.getDatasetMeta(k);
        result.push({
          datasetIndex: k,
          index: i,
          element: meta.data[i]
        });
      }
    }
  }
  return result;
};

the you can set the interaction mode to the tooltip:

plugins: {
  tooltip: {
    mode: 'labels'
  }
},

Leave a comment