1 thought on “Tooltip documentation needs improvements regarding custom tooltips

  1. Until this can be done here are some quick helpers for people looking for answers to common situations:

    Here is how to put together a basic label:

     options: {
          animation: false,
               tooltips: {
                  callbacks: {
                      label: function (tooltipItem, data) { return data.datasets[tooltipItem.datasetIndex].label + ' - ' + tooltipItem.yLabel}
                        }
                    },
    

    And here is how to return a label and then format the number to a currency:

    options: {
      animation: false,
      tooltips: {
            callbacks: {
                label: function (tooltipItem, data) { return data.datasets[tooltipItem.datasetIndex].label + ' - ' + '$' + Number(tooltipItem.yLabel).toFixed(0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
                        }
                    },
    

Comments are closed.