Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the list of options programmatically accessible #875

Open
wlach opened this issue Jun 30, 2018 · 1 comment
Open

Make the list of options programmatically accessible #875

wlach opened this issue Jun 30, 2018 · 1 comment

Comments

@wlach
Copy link
Collaborator

wlach commented Jun 30, 2018

Currently libraries like react-metrics-graphics need to manually specify the properties that they want to support. It would be great if metrics graphics exported such a list itself along with a few other pieces of useful metadata, like their type, for use by such libraries.

Probably the place to start here would be to take this existing defaults list and make it into a library export, adding type information:

The data_graphic method could then process the parameters passed in against this list, warning if a particular property was not specified or was specified with the wrong type.

For processing/handling type information, I am tempted to suggest using the prop-types library (used by react). It's pretty tiny:

https://github.com/facebook/prop-types/

After this is done, we could potentially also use this list to generate documentation, eliminating the need for the current manually maintained list of options:

https://github.com/metricsgraphics/metrics-graphics/wiki/List-of-Options

@cnwangjie
Copy link
Contributor

I submit a PR (#893) just now with a simple list of options. I just simply merged the key of the default option objects in all the charts into an array. This does not be used to verify the type of option or generate a document, but it is enough for us to make a component for React or Vue easily.

If we want to use the list for generating documents, we should define a format for setting the type, description, default value, etc. Because the prop list format of React and Vue are not the same, so if we need to make a component with the validation field function, we should use some code to automatically convert to the format required by the framework.

@wlach What do you think about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants