Get all schemas/attributes as JSON

Hey,

i’m currently trying to write a C# wrapper for the Plotly JavaScript library (project will be published soon).
So I need C# classes that have the same structure as the JavaScript object.
The C# class or method then only calls its counterpart in the JavaScript library.

My goal is to generate this wrapper automatically. For this I need a readable structure that contains all attributes of all traces, configs, etc.
Unfortunately I am not a JavaScript professional. But I found the attributes.js files, which existed for each trace. Is there an easy way to get these attributes as JSON using a function?

I tried to read these attributes locally using node.js, but unfortunately I only get compiler errors like “ReferenceError: window is not defined”. I have never worked with node.js before, so I am a bit overwhelmed.

I would be glad about your support and hope to make Plotly.js possible in the .NET world!

Awesome idea! We do this for the Python and R libraries and others have done it for other languages like Scala.

The up to date reference for the schema is always available at https://raw.githubusercontent.com/plotly/plotly.js/master/dist/plot-schema.json and it’s generated when building the library. We do this for every release and keep this file up to date.

1 Like

Thanks a lot for the link, it was exactly what I was looking for!
More information about the project will follow as soon as it is running!

Have a good start into the week! :slight_smile:

Sounds good! This schema file is also what’s used to generate the docs at https://plotly.com/javascript/reference/ BTW, if you’re looking for a human-readable version :slight_smile:

I also use the schema and a Gradle build to generate a TypeScript definition that is much more expansive than the one currently hosted at DefinitelyTyped.
https://github.com/plotly/plotly.js/issues/28#issuecomment-610383363

1 Like