2

This might be an easy question for someone to answer, but I am very new to Javascript and I am having trouble with this. I'm creating a multigraph with charts.js and I want to set up 2 different tooltips for 2 different data sets. I want the first line graph tooltip to display data point, data set label, and data label (example: 80 ml/pL 07/03/91), I want the second graph (flat dotted line) tooltip to display only the data point and data set label (example: 80 ml/pL).

I was able to create my own custom tooltip so it displays the data point, data set label, and data label, but I am having trouble creating a second custom tooltip for the next data set.

Fiddle here

tooltips: {
              displayColors: false,
                caretSize: 5,
                bodyFontSize: 11,
            callbacks: {
               title: function() {},
               label: function(tooltipItem, data) {
                 if(tooltipItem.datasetsIndex===0){
                      return data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]+ 'ml/pL'+ ' ' + data.labels[tooltipItem.index];
                    } else if (tooltipItem.datasetsIndex===1){
                      return data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index]+ 'ml/pL';
                    }
                  }
            },
        },
Lex Juarez
  • 21
  • 2

0 Answers0