Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
Chartjs - keep tooltip open when user clicks on a datapoint in chart

I have been looking at this thread with the following JSFiddle, which does exactly what I need. Seems like the answer is outdated, but I am not able to get it working.

What I am trying to create a plugin to that will allow the user to click on a datapoint on the chart, and the tooltip will stay open. Then click on another datapoint, and that tooltip will stay open aswell. This will allow the user to more easily compare data in two different tooltips. The "click" event would be useful if it allowed for multiple tooltips at the same time. Any ideas, or pointers to the right direction would be greatly apprieciated!

The following is the plugin from the other thread (creds to Marine Giraud)

var keepTooltipOpenPlugin = {

      beforeRender: function(chart) {
  
    // We are looking for bubble which owns "keepTooltipOpen" parameter.
        var datasets = chart.data.datasets;
        chart.pluginTooltips = [];
        for (i = 0; i < datasets.length; i++) {
          for (j = 0; j < datasets[i].data.length; j++) {
            if (datasets[i].data[j].keepTooltipOpen && !chart.getDatasetMeta(i).hidden) {
            //When we find one, we are pushing all informations to create the tooltip.
              chart.pluginTooltips.push(new Chart.Tooltip({
                _chart: chart.chart,
                _chartInstance: chart,
                _data: chart.data,
                _options: chart.options.tooltips,
                _active: [chart.getDatasetMeta(i).data[j]]
              }, chart));
            }
          }
        }
      }, // end beforeRender
  
      afterDatasetsDraw: function(chart, easing) {

          // Draw tooltips
          Chart.helpers.each(chart.pluginTooltips, function(tooltip) {
            tooltip.initialize();
            tooltip.update();
            tooltip.pivot();
            tooltip.transition(easing).draw();
          });


        } // end afterDatasetsDraw
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!