[Feature] Add validity checker for ECharts options to public header
- Dominant language
- TypeScript
- Stars
- 67.3k
- Forks
- 19.8k
- Avg merge
- 11d 14h
- Merged PRs (30d)
- 8
Description
### What problem does this feature solve?
We are working on an interactive chart builder using ECharts similar to https://echarts.apache.org/examples/en/editor.html?c=line-marker.
Just like this example has an options validator, we would like to have a similar validator in our builder. It seems like that a validator like this is already present in ECharts SDK ecosystem. We would like to request exposing this validator as part of echarts API. This will help us to catch errors in chart configuration before rendering and show errors to the user proactively so that they can fix the errors.
At the moment, the chart configuration may be incorrect and the chart doesn't display any data. The user doesn't have any visual feedback that the configuration is incorrect.
### What does the proposed API look like?
We can have a function called validateOption on global echarts object that accepts options as an argument. It returns an object that contains boolean result true or false depending upon if the chart configuration options are valid or not.
If the chart options are invalid, the function also returns a message property that contains the stack trace or details of error in the configuration and steps to fix it if possible.
```
const { result, message } = echarts.validateOptions(options)
result = false
message = "dataSource is missing in configuration"
```
Screenshot of validator on ECharts example website

Contributor guide
Assessment
This issue has not been assessed yet.