Plotly.js Treemap legend


I am currently looking for a way to have a legend for treemaps just like shown here for Contour Plots

I want to be able to define my own range and set the colors for each value. How can I achieve this? I haven’t found a way to manually create legends, rather they seem to be implemented on a per chart basis.

Thanks in advance

Here is a demo.
Hope it may help.