[Bug] Float64Array can not be used in a dataset unless the X is converted to an array: const x = Array.from(new Float64Array([1,2,3,4,5,6,7,8,9,10]));
Version
5.2.2
Link to Minimal Reproduction
https://github.com/apache/echarts/issues/10223
Steps to Reproduce
Have a look to https://github.com/apache/echarts/issues/10223 each steps are described to reproduce it. Very easy
Current Behavior
need to have x of the dataset as an array:
const x = Array.from(new Float64Array([1,2,3,4,5,6,7,8,9,10]));
Expected Behavior
To not have to convert to array.
Environment
- OS:macOS Monterey
- Browser: Chrome 96.0.4664.55
- Framework:any
Any additional comments?
Sorry, for this, but the original issue was closed by the original poster as he found a workaround (the Array.from conversion), but this is still a bug, this conversion shall not be needed, and in case of HUGE ;-) dataset like millions of timestamp, this is still a problem as it double the RAM needed, without speaking of the optimisation lost by NOT using Float64Array directly.
https://github.com/apache/echarts/issues/10223 : this is the original ticket.
Thank you very much in advance for your consideration :)
Hi, @anymos I'm not sure if this is an unexpected case. According to the source code, it doesn't handle the case when the source data is a regular array that contains typed arrays. Perhaps, you can try to use the workaround 2(using a one-dimension typed array) mentioned in #10223.
Hi @plainheart , thank you to come back to me that quick, it's really cool.
I agree that the current source code do not handle that case with dataset as a row (regular array with typed arrays) Meanwhile the work around that you propose could work for small data set, it get in a way of huge data set in the form of typeArray.
An exemple to illustrate this with a time series from financial, it is lot easier to manage typeArray extends by concatenating them using binary copy when the dataset are in row with [[time][price][etc ...] than using a one dimension array,.
With a one time dimension array you can not add a new variable easily as you have to recompute the full one dimension array to add them inside for each of them.
Beside, with one dimension array, you need to keep only one typed array Float64 or int64 , with multiple dimension you can have [float64,int64, etc ...]
Which is more optimal from a RAM perspective.
In my use case there is millions of records and it impact the RAM quite a bit.
In understand that it is maybe not a priority, and I am not too sure of the complexity involved to make this happens.
I let you judge you know a lot better than me the underlying code and dependency.
In the mean time, thank you again for your time to read and review that ticket.
Have a good day moving forward !
@anymos Thanks for your detailed information! Perhaps, @100pah and @pissang, the author of the dataset component, can provide you with further help.
Good morning! you are welcome @plainheart ! I did not hear from @100pah or @pissang , but I believe they are probably busy fixing more urgent bug. In the mean time I believe I found another bug related to dataset that might be more blocking, I described it here : https://github.com/apache/echarts/issues/17479
Have a good day moving forward !
Hi there a little bump on this, any idea if it could be fixed easily ?
Hi there a little bump on this, any idea if it could be fixed easily ?
@anymos Hi Raphael, I'm not sure if the following way can help you but just take it a try.
Please find isArray in https://github.com/apache/echarts/blob/master/src/data/Source.ts#L274 in your local dist file and change it to isArrayLike. I didn't do more tests for it but at least it works with this demo code.
@plainheart it is actually not working with you demo code as it is not using the same as the one described in https://github.com/apache/echarts/issues/10223
`const x = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); const y = new Float64Array([36, 20, 53, 44, 35, 46, 97, 38, 19]);
option = {
xAxis: { type: 'value' },
yAxis: { type: 'value' },
dataset: {
dimensions:[
{ name: 'x', type: 'float'},
{ name: 'y', type: 'float'}
],
source: [
x, y
],
},
series: {
type: 'line',
sampling: 'max',
encode: {
'y': 'y',
'x': 'x'
},
seriesLayoutBy: 'row'
}
};`