apache / echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser
https://echarts.apache.org
Apache License 2.0
60.63k stars 19.61k forks source link

implement aggregate transformer #15306

Open 100pah opened 3 years ago

100pah commented 3 years ago

At present the there is only a simplest aggregate transformer in echarts-simple-transform/aggregate. We should better implement a built-in aggregate transformer in echarts.

About the API

Think of whether the API of echarts-simple-transform/aggregate appropriate.

About group by

In echarts-simple-transform/aggregate only on dimension can be set in group by. Do we need to support multiple dimension group by?

About Methods

Some methods of aggregate already roughly implemented in echarts-simple-transform/aggregate:

We need to make sure they are implemented correctly.

Other methods we may implement:

Some references: vega aggregate.

About math calculation precision

We all known that the floating precision issue (like 0.1 + 0.2). It might bring trouble in some scenarios like:

Some cases:

0.1 + 0.2 === 0.30000000000000004
2.3 - 0.3 === 1.9999999999999998
33643.2 - 15918.3 === 17724.899999999998
146.39 - 62.83 === 83.55999999999999
1.09 - 0.13 === 0.9600000000000001
0.1 * 0.2 === 0.020000000000000004
16.08 * 100 === 1607.9999999999998
146.39 * 100 === 14638.999999999998
9999999999999999 === 10000000000000000
-11.699999999999986 === -11.699999999999987

We should also take care the toFixed bug like:

1.005.toFixed(2) === '1.00' // rather than '1.01'
0.1.toFixed(20) === '0.10000000000000000555'

Solution:

See: IEEE 754, http://0.30000000000000004.com/, https://github.com/camsong/blog/issues/9, https://javascript.info/number#imprecise-calculations, ... (lots of related references)

Some library:

About big number

Do not support.

Test

Could find some test cases in some other math libraries.

maneetgoyal commented 2 years ago

Would be great to have this feature 💯

sumitnegi7 commented 2 years ago

@100pah Seems like a pretty useful feature

saikat-samanta commented 2 years ago

This feature seems really helpful. 👍

Prit-sangani commented 2 years ago

Yes, this feature is very helpful. Would be great to have this feature.

VirajBhatt9 commented 2 years ago

It is a very great feature. It would be very helpful to have this feature.

swapnil0545 commented 1 year ago

Any update on merging this?

MrZhouZh commented 10 months ago
image

This feature that i really want it. cannot wait