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/07/15 09:00:49 UTC

[GitHub] [incubator-echarts] allen-kobe opened a new issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

allen-kobe opened a new issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970


   ### Version
   4.8.0
   
   ### Steps to reproduce
   [{
       value: '-',
       name: '综合健康评分'
   }]
   
   ### What is expected?
   如果我传的值是‘-’,则显示-,而不是直接显示NAN
   
   ### What is actually happening?
   如果传入非数值型数据,则显示NAN
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   


----------------------------------------------------------------
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] [incubator-echarts] allen-kobe commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
allen-kobe commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-659089152


   > 仪表盘的data的数据类型应为 `number`, 默认会把数据值当作数字进行格式化,`-` 不能被正常转化为`number`,因此出现`NaN`。
   > 暂时可以按照 @quillblue 说的 `formatter` 的回调函数自行处理。
   > 不过我认为这应该可以被enhanced一下。
   
   是的,只是不太理解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


[GitHub] [incubator-echarts] allen-kobe commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
allen-kobe commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-658652273


   > Hi! We've received your issue and please be patient to get responded. 🎉
   > The average response time is expected to be within one day for weekdays.
   > 
   > In the meanwhile, please make sure that **you have posted enough image to demo your request**. You may also check out the [API](http://echarts.apache.org/api.html) and [chart option](http://echarts.apache.org/option.html) to get the answer.
   > 
   > If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to [dev@echarts.apache.org](mailto:dev@echarts.apache.org). Please attach the issue link if it's a technical questions.
   > 
   > If you are interested in the project, you may also subscribe our [mail list](https://echarts.apache.org/en/maillist.html).
   > 
   > Have a nice day! 🍵
   
   ![image](https://user-images.githubusercontent.com/68325209/87527783-2f218300-c6bf-11ea-8c70-1a1375f28a29.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] [incubator-echarts] plainheart commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
plainheart commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-659087490


   仪表盘的data的数据类型应为 `number`, 默认会把数据值当作数字进行格式化,`-` 不能被正常转化为`number`,因此出现`NaN`。
   暂时可以按照 @quillblue 说的 `formatter` 的回调函数自行处理。
   不过我认为这应该可以被enhanced一下。


----------------------------------------------------------------
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] [incubator-echarts] quillblue commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
quillblue commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-659327763


   > > 仪表盘的data的数据类型应为 `number`, 默认会把数据值当作数字进行格式化,`-` 不能被正常转化为`number`,因此出现`NaN`。
   > > 暂时可以按照 @quillblue 说的 `formatter` 的回调函数自行处理。
   > > 不过我认为这应该可以被enhanced一下。
   > 
   > 是的,只是不太理解echarts内部为啥需要格式化,是不是有什么特殊的情况
   
   我的理解是,echarts在render图表的时候肯定会需要一个数值化的value来渲染图表(指针的位置),在绘制label的时候使用了这个数值化后的value而不是原来传入的value。
   但直接使用原来传入的value的缺陷是,formatter回掉函数里不能简单假设入参一定是数字,使用toFixed之类的函数作为回掉函数的话会抛错而引起整个渲染的中断,这个问题会在未来TypeScript的强类型中变得更明显。@plainheart 这也是我不认为适合在此处enhance的原因。


----------------------------------------------------------------
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] [incubator-echarts] plainheart commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
plainheart commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-659345362


   @quillblue 我同意你的看法,不过我说的 enhance 并非是直接使用原来传入的 value,而是在 `formatLabel` 时判断是否 value 为非数值类型,如果不是数值类型,如 `null`, `undefined`, `NaN` 等,默认显示为 `0` 而不是 `NaN`,因此我认为这可以被enhance。
   但由于这个借助 formatter 的回调函数增加自己的处理逻辑可以非常简单地实现,故不是很有必要更改代码逻辑。


----------------------------------------------------------------
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] [incubator-echarts] quillblue edited a comment on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
quillblue edited a comment on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-658781186


   @allen-kobe 
   使用[series(gauge).detail.formatter](https://echarts.apache.org/en/option.html#series-gauge.detail.formatter) 的回调函数可以解决这个问题。下面的代码给出了一个样例。
   
   `formatter: function (value) {
      if (isNaN(value)) {
           return '-'
      } 
      else {return value};
   }`
   
   For community, I don't think this is a bug.


----------------------------------------------------------------
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] [incubator-echarts] echarts-bot[bot] commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

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


   Hi! We've received your issue and please be patient to get responded. 🎉
   The average response time is expected to be within one day for weekdays.
   
   In the meanwhile, please make sure that **you have posted enough image to demo your request**. You may also check out the [API](http://echarts.apache.org/api.html) and [chart option](http://echarts.apache.org/option.html) to get the answer.
   
   If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.
   
   If you are interested in the project, you may also subscribe our [mail list](https://echarts.apache.org/en/maillist.html).
   
   Have a nice day! 🍵


----------------------------------------------------------------
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] [incubator-echarts] quillblue commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
quillblue commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-658781186


   @allen-kobe 
   使用[series(gauge).detail.formatter](https://echarts.apache.org/en/option.html#series-gauge.detail.formatter) 的回掉函数可以解决这个问题。下面的代码给出了一个样例。
   
   `formatter: function (value) {
      if (isNaN(value)) {
           return '-'
      } 
      else {return value};
   }`
   
   For community, I don't think this is a bug.


----------------------------------------------------------------
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] [incubator-echarts] allen-kobe commented on issue #12970: 关于仪表盘data值为空的时候,显示NAN的问题

Posted by GitBox <gi...@apache.org>.
allen-kobe commented on issue #12970:
URL: https://github.com/apache/incubator-echarts/issues/12970#issuecomment-659089031


   > @allen-kobe
   > 使用[series(gauge).detail.formatter](https://echarts.apache.org/en/option.html#series-gauge.detail.formatter) 的回调函数可以解决这个问题。下面的代码给出了一个样例。
   > 
   > `formatter: function (value) { if (isNaN(value)) { return '-' } else {return value}; }`
   > 
   > For community, I don't think this is a bug.
   
   确实可以通过这个方法解决,只是不理解,为啥echarts内部需要对这个value进行数字格式化呢?是不是有什么特殊的情况


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