echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] Line mode, detect missing time points and choose weither connect line or not or with which threshold

Open pasch82-code opened this issue 1 year ago • 1 comments

What problem does this feature solve?

Seems like Echarts when it's 'line' mode is not able to understand a missing time point, it just connects the line.

const data = [ { name: '2024-04-13', value: ['2024-04-13', '100'] }, { name: '2024-04-15', value: ['2024-04-15', '400'] }, { name: '2024-04-17', value: ['2024-04-17', '500'] }, { name: '2024-04-18', value: ['2024-04-18', '600'] }, ]; series: [{ data, type: 'line' }, ]

this data with line type: image

the same data with ‘bar’ type, will show empty time data points image

I noticed that if the series are different, Echarts is already able to generate the empty space, so I would like to achieve a similar result but without splitting the original serie in multiple series:

image

this was done with this data: const data1= [ { name: '2024-04-13', value: ['2024-04-13', '100'] }, { name: '2024-04-14', value: ['2024-04-14', '300'] }, ]; const data2 = [ { name: '2024-04-16', value: ['2024-04-16', '400'] }, { name: '2024-04-17', value: ['2024-04-17', '450'] }, ]; const data3 = [ { name: '2024-04-19', value: ['2024-04-19', '500'] }, { name: '2024-04-20', value: ['2024-04-20', '200'] }, ]; series: [ { data: data1, type: 'line' }, { data: data2, type: 'line' }, { data: data3, type: 'line' }, ]

What does the proposed API look like?

It would be nice to be able to choose whether or not to connect/disconnect the line.

It would be very nice to solve this similar to how Grafana solves this problem: https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/time-series/#disconnect-values (using never or with a Threshold )

Disconnect values Choose whether to set a threshold above which values in the data should be disconnected.

Never - Time series data points in the data are never disconnected. Threshold - Specify a threshold above which values in the data are disconnected. This can be useful when desired values in the data are of a known size and/or within a known range, and values outside this range should no longer be connected.

pasch82-code avatar Dec 10 '24 16:12 pasch82-code

You can achieve a similar effect by preprocessing your data and adding null values if your threshold is exceeded.

Example

MatthiasMert avatar Dec 11 '24 13:12 MatthiasMert