apache / apache/echarts

[Feature] Add validity checker for ECharts options to public header

Open
#19,046 2 comments 2 reactions 0 assignees View on GitHub
en new-feature pending
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

![Screenshot 2023-08-28 at 12 06 22 PM](https://github.com/apache/echarts/assets/1189106/271d7113-78da-403b-9f1c-a4825680c244)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.