How to get the colorvalue of pixel clicked on a heatmap


I have a heatmap with certain colorscale e.g. “Rainbow”, when I clicked on a pixel, I would like to get the color of that pixel in rgb values (or any html supported format) I have searched the documentation everywhere and have not found any method. Anyone tried something like this?