I have been using JSROOT to draw histograms in a web browser. The configuration of the web page is saved in a database (e.g., colors and font parameters of the histograms interactively selected by the user).
However, if a user interactively selects a non-default draw option for some histograms, I haven’t found a way to extract and preserve this information. Is it possible to retrieve this information from the canvases and save it in permanent storage so that the next time the same page is loaded, the last-used draw options will be applied to the histograms?
Thank you for the suggestion. I have tried to implement it, but unless I’m doing something wrong, it was unsuccessful. The Painter.getDrawOpt() always returns the original draw option that I passed to the draw() function (‘hist’ in my case). Any interactive modifications which have been done via the “Draw with” drop-down menu command are ignored.
Cheers
PS: I’ using version 7.9.1 which seems to be the latest.
If you are using draw function - all previous painter objects are removed and then created new.
You can use redraw function instead. Or always remember last painter object returned from last draw call. Also small update how redraw method should be used:
Yes, I know that if I redraw a histograms the manually chosen draw option will be preserved in the current session. My question is if I can get the value of currently manually selected draw option to save it to some persistent storage and reuse when the web page with the histograms is reloaded?
I think I understand the difference between your example and my tests. In your example, you are drawing a histogram object (JSON obtained with type=compact), while in my application I draw a Canvas (JSON obtained with type=json). In that case, getDrawOpt() always returns an empty string.
In fact, my earlier claim about 2D histograms was incorrect. When drawing a Canvas instead of a histogram, getDrawOpt() always returns an empty string, regardless of the histogram dimension.
When you draw canvas - you got canvas painter after draw.
To get individual painter of each object - use painter.findPainterFor(null,'hist_name')
If only histogram drawn on the canvas - also painter.getMainPainter() can be used.