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 2021/03/04 20:28:08 UTC

[GitHub] [echarts] jonavila commented on issue #14293: 配置项series.data数组里如果同时存在null和对象,将会报错Cannot read property 'selected' of null

jonavila commented on issue #14293:
URL: https://github.com/apache/echarts/issues/14293#issuecomment-790918020


   I ran into this issue in 5.x and I believe it's caused by this method of Series.ts
   
   
   ```
   private _initSelectedMapFromData(data: List) {
           // Ignore select info in data if selectedMap exists.
           // NOTE It's only for legacy usage. edge data is not supported.
           if (this.option.selectedMap) {
               return;
           }
   
           const dataIndices: number[] = [];
           if (data.hasItemOption) {
               data.each(function (idx) {
                   const rawItem = data.getRawDataItem(idx);
                   if (typeof rawItem === 'object'
                       && (rawItem as OptionDataItemObject<unknown>).selected
                   ) {
                       dataIndices.push(idx);
                   }
               });
           }
   
           if (dataIndices.length > 0) {
               this._innerSelect(data, dataIndices);
           }
       }
       
   ```
   You can see how it fails if rawItem is null because typeof null === 'object'.
   
   Using  undefined in the value instead of null works for me as workaround.
   
   
   


----------------------------------------------------------------
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



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