Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Access color scale in Plotly javascript

How can I get in javascript the color scales defined in the variable scales in
https://github.com/plotly/plotly.js/blob/master/src/components/colorscale/scales.js?

I inspected the Plotly object in debugger console, but I can’t find the attributes.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

as far as I can tell by the way the project is bundled, if you are using the release version of the project (like the one in the CND or the dist folder) you cannot access them, because they are only defined directly in the function that uses them. So they are not exposed in any property or anything. (see image from the bundled file below)

enter image description here

Note: As mentioned in @Aifos answer, it was available but since version 2, Plotly no longer exposes .d3 property so if you use last version you will get an error

If you need them I’d recommend you to simply import the file yourself from the src file

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading