Check if chart/trace requires WebGL

Given trace type (string property from data element), is there any reliable way to check if it requires webgl to be rendered?

The case might be: handling webgl failures and implementing some sort of failover for webgl charts. There are many trace types and it is hard to tell whether or not some of them need webgl internally to be rendered.

Primitive cases when type just ends with “gl” suffix impose webgl version of some basic chart. But there are some non-evident cases, for example pointcloud, when it is not clear from
documentation or source code investigation.

There is also “plotly_webglcontextlost” event. Unfortunately, it is not emitted when webgl is completely unavailable (turned off, for example) and only a js error occurs.

var gd = document.getElementById(/* id of your graph */)

gd._fullLayout._has('gl')  // return true or false

is probably the best way at the moment. Be careful though when upgrading your plotly.js version as this isn’t part of our official API and can change w/o notice.

Thanks for posting. We’ll consider adding an official helper method similar to _has.