Chartjs-ChartJS legend background color while using point styles

1👍

Solved.

  1. The solution is to maintain the code as it is
  2. The solution is here https://stackoverflow.com/a/43173498/3355243
  3. The solution is below

Applies the colors of the tooltips taking in consideration the dataset index.

options:
{
    tooltips:
    {
        mode: 'index',
        intersect: false,
        callbacks:
        {
            labelColor: function(tooltipItem, chart)
            {
                var datasetIndex = tooltipItem.datasetIndex;
                var borderColor = chart.legend.legendItems[datasetIndex].fillStyle;
                var backgroundColor = chart.legend.legendItems[datasetIndex].fillStyle;

                return {
                    borderColor: borderColor,
                    backgroundColor: backgroundColor
                };
            },
        }
    },
}

Leave a comment