You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2020/04/03 08:26:26 UTC

[GitHub] [incubator-echarts] EqualMa commented on issue #10223: Echarts 对TypedArray的支持问题

EqualMa commented on issue #10223: Echarts 对TypedArray的支持问题
URL: https://github.com/apache/incubator-echarts/issues/10223#issuecomment-608301672
 
 
   To reproduce this issue:
   
   Open [echarts online editor](https://www.echartsjs.com/examples/zh/editor.html) and paste the following coding, click *Run*
   
   ## repro the issue
   
   ```js
   const x = new Float64Array([1,2,3,4,5,6,7,8,9,10]);
   const y = new Float64Array([34,7657,235.5,54,0,5477,3325,500,4000,2000]);
   
   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'
     }
   };
   ```
   
   It doesn't work.
   
   ## workaround 1
   
   With `x` being a js array, it works. (You don't even need to change `y`)
   
   ```js
   const x = Array.from(new Float64Array([1,2,3,4,5,6,7,8,9,10]));
   ```
   
   ## workaround 2
   
   Note that the following code also works:
   
   ```js
   const data = new Float64Array([1,34, 2,7657, 3,235.5, 4,54, 5,0, 6,5477, 7,3325, 8,500, 9,4000, 10,2000])
   
   var option = {
     xAxis: { type: 'value' },
     yAxis: { type: 'value' },
     dataset: {
       dimensions:[
         { name: 'x', type: 'float'}, 
         { name: 'y', type: 'float'}
       ],
       source: data // NOTE: use an one dimension Float64Array to represent [x1, y1, x2, y2, ...]
     },
     series: {
       type: 'line',
       sampling: 'max',
       encode: {
         'y': 'y',
         'x': 'x'
       },
       seriesLayoutBy: 'row'
     }
   };
   ```
   
   So I guess using an one dimension Float64Array to represent `[x1, y1, x2, y2, ...]` is the proper way to use TypedArray, but I couldn't find any docs about that, though the main page of the site says it features supporting TypedArray. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org