-
Notifications
You must be signed in to change notification settings - Fork 87
-
Hi, I am currently building an application where people can customise their template in json plotly standard (not sure if there is a standard, just the one used in javascript). {
"data": [...],
"layout": {...},
"frames": [...]
} Is it possible to create a GenericGraph starting from the json without having to map each single property? |
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments · 1 reply
-
The thing with our strongly typed layers is that they unfortunately only work well for JSON creation. plotly.js JSON has properties that have arbitrary types, which you can do in a dynamically typed language such as JavaScript or python, but is quite hard to do in .NET. We circumvent this on object creation by offering a strongly typed subset of possible types and by using Your use case is especially hard, because chart templates are basically allowing all possible plotly objects. I'd suggest only providing the options to set a subset of template properties and expand with what is needed. But maybe a pointer to the code where we implement the plotly template at least helps a little: Plotly.NET/src/Plotly.NET/Templates/ChartTemplates.fs Lines 168 to 701 in 11456b4
|
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Oh, quite hacky solution, but you could include the template as javascript in the output of this lib by patching the generated html string for a chart, e.g. by replacing the actual template in the output of |
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you for the explanation! Another approach I might follow is to use directly the plotty js library and run the application through puppeter to generate the image! |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
The thing with our strongly typed layers is that they unfortunately only work well for JSON creation. plotly.js JSON has properties that have arbitrary types, which you can do in a dynamically typed language such as JavaScript or python, but is quite hard to do in .NET.
We circumvent this on object creation by offering a strongly typed subset of possible types and by using
DynamicObj
, which lets us set members dynamically. However, this basically prevents deserialization - even if you could deserialize all nested objects intoDynamicObj
(which does not work), there is no way of knowing whether thatDynamicObj
represents aTrace
, aLinearAxis
, or any other strong type abstraction provided …