Get bar value when onClick Reactjs

0👍

Sorry, a found the answer :

 <Line
      data={chartData}
      options={options}
      onElementsClick={elems => {
        // if required to build the URL, you can
        // get datasetIndex and value index from an `elem`:

        var activePoint = elems[0];
        var data = activePoint._chart.data;
        var datasetIndex = activePoint._datasetIndex;
        var label = data.datasets[datasetIndex].label;
        var value = data.datasets[datasetIndex].data[activePoint._index];
        alert(value);
        // and then redirect to the target page:
      }}
    />

Leave a comment