0

I have a chart.js chart that graphs data. I want to have a tooltip that when hovered over it has some commentary say "Here is (1,1)".

I have already searched through their documentation and have found that the only customization you could have for tooltips was colored and that applies to every tooltip.

let stockGraph = new Chart(myChart, {
    type:'line', //bar, horizontalBar, pie, line, donut, radar, polarArea
    data:{
        labels:["Hi", "I", "love"],
        datasets:[{
            data:[1,2,3],
            fill: false,
            lineTension: 0,
        }]
    },
    options:{
        title:{
            display:true,
            text:"Please enter a stock",
            fontSize: 25,
        },
        legend:{
            display:false,
        },
        tooltips:{
            enabled:true,
        },
    }
});

My expected result is to be able to hover over Hi,1 and have the tooltip read "this is (Hi,1)" then hover over I,2 and have the tooltip read "This is (I,2)" is there a way to accomplish this with chart.js? Thank you so much! The other question about chart.js documentation didn't answer my question because it does not show how to show a specific coordinate.

  • 1
    Possible duplicate of [Chart JS custom tooltip option?](https://stackoverflow.com/questions/25338141/chart-js-custom-tooltip-option) – Murtaza Hussain May 12 '19 at 00:23
  • I don't think it is because that doesn't mention how to make it at a specific point – Sam Schnaars May 12 '19 at 00:33
  • You will need to make use of the tooltip `custom` property mentioned in the docs (https://www.chartjs.org/docs/latest/configuration/tooltip.html#external-custom-tooltips). The `tooltipModel` property passed to the function you provide will contain the details needed to determine which point the tooltip is for. – Daniel W Strimpel May 12 '19 at 00:59

0 Answers0