Plot support refactor
Our current plotting functionality is quite limited. In customs schemas one can define
PlotAnnotations for sections or quantities, but they don't offer enough functionality in many cases.
- Only static configuration is allowed. I guess the origin of this is the use in yaml schemas which can't really contain code. What if the layout or plotted traces should change based on data that is being plotted? What if we need to perform some postprocessing to the data before plotting? There was already a request coming from @jschumann about being able to determine the visualization of different lines when it is not known how many lines will be plotted.
- The attributes in our
PlotAnnotationis not completely aligned with the way Plotly plots are created.
- Plot needs to be associated with a section or quantity. What if I want to define it in a completely custom location?
Plotly plots can be configured with JSON: Each plot takes in
config, more info here. If we are able to produce a single JSON dictionary:
This could be loaded from our API and visualized directly. It would only be a matter of how this JSON data is created and rendered:
- It could similar to a
derivedvalue: The data would be created on the fly when requesting it from the API.
- It could be a quantity with JSON dtype that is filled by a normalize-function of a custom schema. This would mean it is persisted always and there is data duplication. There could be a special annotation that tells that Plotly should be used to view this JSON file within an ELN.
- Maybe we could create a special type of
Quantityfor plots? This might be easier for users to grasp. This special quantity could then maybe be configured to either store the plot, or always recreate it on the fly.
This solution would only be available in python schemas, since it requires specifying python code. But I think this should be an acceptable limitation.