In the documentation, it is written:
ECharts supports TypedArray, which occupies less memory than array and is more gabbage-collection-friendly. For big data visualization, it is suggested to use TypedArray to improve performance.
Yet this fail (using either float32 or float64):
dataset:{ dimensions: [ {name: 'x', type: 'float'}, {name: 'y', type: 'float'} ], source: [ Float32Array.from([1, 2, 3, 4, 5]), Float32Array.from([6, 7, 8, 9, 10]) ] }
While interestingly this works:
dataset:{ dimensions: [ {name: 'x', type: 'float'}, {name: 'y', type: 'float'} ], source: [ [1, 2, 3, 4, 5], Float32Array.from([6, 7, 8, 9, 10]) ] }
1条答案
按热度按时间cpjpxq1n1#
Yet this fail (using either float32 or float64):
dataset:{ dimensions: [ {name: 'x', type: 'float'}, {name: 'y', type: 'float'} ], source: [ Float32Array.from([1, 2, 3, 4, 5]), Float32Array.from([6, 7, 8, 9, 10]) ] }
This first version using two Float32Arrays doesn't work because the
sourceFormat
is detected asSOURCE_FORMAT_OBJECT_ROWS
. Looking here (current master branch):https://github.com/apache/incubator-echarts/blob/f765b203791b2a452cb5418d55e97a076ce532dc/src/data/Source.ts#L308-L310
The second version works since the check marks it as
SOURCE_FORMAT_ARRAY_ROWS
, which is what we want.Just updating the check from
to
seems to be enough to make it work with typed arrays without extra conversions. I tested with line and bar series, no issues so far. I'll report back if I hit other issues.
@pissang, in another ticket, similar usage but without
dataset
, you mentioned this wasn't in the plans (#13335 (comment) in reply to @lukasberbuer). Would you consider this small change to enable us to use adataset
with a list of typed arrays?