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/02/26 06:37:28 UTC

[GitHub] [echarts] pumpkinduan opened a new issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

pumpkinduan opened a new issue #14358:
URL: https://github.com/apache/echarts/issues/14358


   <!--
   Please Use https://ecomfe.github.io/echarts-issue-helper to create the issue.
   Otherwise, it will be closed immediately.
   Questions in the form of *How to use ...* should be at Stack Overflow rather than GitHub issue list.
   
   请注意,所有 issue 必须由 https://ecomfe.github.io/echarts-issue-helper/ 创建,不然将会被直接关闭。建议使用英文提问。
   Issues 中不要问「如何使用 ECharts 实现……功能」的问题,相关问题请到 SegmentFault 或 Stack Overflow 提问,详见上面的链接。
   -->
   我给series赋值了一个二维数组,最内层的数组成员包含了对象和null或undefined的值,TS编译会报错,传值是按照官网的示例来的[series data](https://echarts.apache.org/zh/option.html#series-line.data.value),如下图:
   ![image](https://user-images.githubusercontent.com/34852848/109263951-268d4f80-783f-11eb-8861-9e2f35f6a89b.png)
   
   为了找出原因,我去看了相关的类型定义,发现data成员的值现在是 三种类型的值,但是我传入其他类型的值,将类型改成any后,项目还是可以跑的,**请问这个会以后有什么影响呢**?
   
   ![image](https://user-images.githubusercontent.com/34852848/109264323-c519b080-783f-11eb-8e77-4809a53e4726.png)
   
   ![image](https://user-images.githubusercontent.com/34852848/109264369-dbc00780-783f-11eb-8cfa-844d45e2bab3.png)
   
   
   


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


[GitHub] [echarts] echarts-bot[bot] closed issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] closed issue #14358:
URL: https://github.com/apache/echarts/issues/14358


   


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


[GitHub] [echarts] pissang commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pissang commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786505288


   data 的格式是下面这样
   
   ```ts
   [
     [1, 2, 3, 4]  // 每个数据项都是一个多维数据的数组
   ]
   ```
   
   ```ts
   [
     // 每个数据项是一个对象,其中 value 是包含多维数据的数组,其它属性可以是 itemStyle 设置样式,也可以是其它自己临时存放的并不是给 echarts 用的东西
     {
       value: [1, 2, 3, 4]
     }
   ]
   ```


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


[GitHub] [echarts] pumpkinduan commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pumpkinduan commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786519177


   > data 的格式是下面这样
   > 
   > ```ts
   > [
   >   [1, 2, 3, 4]  // 每个数据项都是一个多维数据的数组
   > ]
   > ```
   > 
   > ```ts
   > [
   >   // 每个数据项是一个对象,其中 value 是包含多维数据的数组,其它属性可以是 itemStyle 设置样式,也可以是其它自己临时存放的并不是给 echarts 用的东西
   >   {
   >     value: [1, 2, 3, 4]
   >   }
   > ]
   > ```
   
   **您好,很感谢您的回复!  还请在看看下面的现象**
   
   传递的data数组格式如下图,它在5.x版本中是可以正常渲染出来的,不过ts类型会报错,也就是上面我发的图
   其中,索引为 2和3的项是临时存放的对象,
   
   ![image](https://user-images.githubusercontent.com/34852848/109279658-fb155f80-7854-11eb-99be-b64930d28db6.png)
   
   [参照官方文档](https://echarts.apache.org/zh/option.html#series-line.data.value)
   
   ```
    [
       12,
       34,
       {
           value : 56,
           //自定义标签样式,仅对该数据项有效
           label: {},
           //自定义特殊 itemStyle,仅对该数据项有效
           itemStyle:{}
       },
       10
   ]
   // 或
   [
       [12, 33],
       [34, 313],
       {
           value: [56, 44],
           label: {},
           itemStyle:{}
       },
       [10, 33]
   ]
   ```


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


[GitHub] [echarts] pissang edited a comment on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786555159






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


[GitHub] [echarts] pissang commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pissang commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786555159


   嗯,因为代码会有一定的容错处理,有些是有意的,有些是无意的,比如这个例子中是因为第三项没有用到被忽略了所以什么类型都能正常渲染。
   
   通常来说类型会有更严格的约束来替代一些代码中不好做的检查。比如检查每个数据格式是否合法,这个如果是代码逻辑判断,可能会带来很多额外的开销以及代码体积


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


[GitHub] [echarts] pumpkinduan commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pumpkinduan commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786489849


   > 看起来 data 多嵌套了一层数组?
   
   不是的,data是可以接受二维数组的,我把那个 {value: 2}这个成员去掉,就不会有ts的提示错误了,关键在于这个data只接受三种类型的值了:string | number | Date


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


[GitHub] [echarts] pissang commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pissang commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786487015


   看起来 data 多嵌套了一层数组?


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


[GitHub] [echarts] echarts-bot[bot] commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786445655


   This issue is not created using [issue template](https://ecomfe.github.io/echarts-issue-helper/) so I'm going to close it. 🙊
   Sorry for this, but it helps save our maintainers' time so that more developers get helped.
   Feel free to create another issue using the issue template.
   
   If you think you have already made your point clear without the template, or your problem cannot be covered by it, you may re-open this issue again.
   
   这个 issue 未使用 [issue 模板](https://ecomfe.github.io/echarts-issue-helper/?lang=zh-cn) 创建,所以我将关闭此 issue。
   为此带来的麻烦我深表歉意,但是请理解这是为了节约社区维护者的时间,以更高效地服务社区的开发者群体。
   如果您愿意,请使用 issue 模板重新创建 issue。
   
   如果您认为虽然没有使用模板,但您已经提供了复现问题的充分描述,或者您的问题无法使用模板表达,也可以重新 open 这个 issue。


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


[GitHub] [echarts] pumpkinduan commented on issue #14358: 在echarts5.0.2 版本中,给option的series赋值,TS编译报错

Posted by GitBox <gi...@apache.org>.
pumpkinduan commented on issue #14358:
URL: https://github.com/apache/echarts/issues/14358#issuecomment-786588901


   大体上我明白了,现在对data中的数据格式做了更严格的定义,所以才会有了上面的错误,能正常渲染是因为echarts内部做了一定的容错处理。
   
   非常感谢您的解答,祝元宵快乐


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