This PR adds a unique identified to each viewer that will be added as a class for the root element of the FigureWidget in the DOM. This allows a client that can also run JS in the browser (e.g. a Vue component being used in a Solara app) an easy way to directly reference any figure(s) for a given viewer from a JS context in the browser. Note that this is a class, not an id - each view of the FigureWidget will have the same class. This class is accessible Python-side as viewer.unique_class.
The class is constructed from a v4 UUID in order to be unique. The format of the class is glue-plotly-<UUID>. This format has two purposes:
Make sure that the class starts with a letter
Clearly tell where this class is being applied from
This PR adds a unique identified to each viewer that will be added as a class for the root element of the
FigureWidget
in the DOM. This allows a client that can also run JS in the browser (e.g. a Vue component being used in a Solara app) an easy way to directly reference any figure(s) for a given viewer from a JS context in the browser. Note that this is a class, not an id - each view of theFigureWidget
will have the same class. This class is accessible Python-side asviewer.unique_class
.The class is constructed from a v4 UUID in order to be unique. The format of the class is
glue-plotly-<UUID>
. This format has two purposes: