You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2018/10/17 09:43:22 UTC

[GitHub] a523 opened a new issue #9244: series.data 是否支持key-value 形式(对象数组)的数据

a523 opened a new issue #9244: series.data  是否支持key-value 形式(对象数组)的数据
URL: https://github.com/apache/incubator-echarts/issues/9244
 
 
   <!--
   为了方便我们能够复现和修复 bug,请遵从下面的规范描述您的问题。
   -->
   
   
   ### One-line summary [问题简述]
   我在官网文档看到dataset.source支持 key-value 形式(对象数组),并且自己对照文档也实现了,但是我改用series.data 里面填入下面这样的数据,图表却出不来
   
   
   ### Version & Environment [版本及环境]
   + ECharts version [ECharts 版本]:  4
   + Browser version [浏览器类型和版本]:  chrome
   + OS Version [操作系统类型和版本]: mac
   
   
   ### 期望结果 [期望结果]
   官网能出一篇好一点的关于怎么传数据给Echarts用的教程吗?(也就是Echart的数据接口, 刚接触感觉Echarts数据接口好奇怪, 琢磨了好几天才上摸到一点点,还得看了林在网易云的视频教程才好一点点, 但是那个教程也很老了,里面没有讲dataset),5分中上手的教程太简单, 不适用大多情况, 异步加载数据教程也没有用dataset做实例。看了好几天才明白, 把返回给Echarts的数据看出一个excel表格就好了, 第一行是表头一般表x轴。可是一般后端返回的数据都是json,key-val格式,习惯了。刚接触好难理解, 官网要在介绍data 的时候,最开始的时候就明说, 就好理解一点。
   
   
   ### ECharts option [ECharts配置项]
   <!-- Copy and paste your 'echarts option' here. -->
   <!-- [下方贴你的option,注意不要删掉下方 ```javascript 和 尾部的 ``` 字样。最好是我们能够直接运行的 option。如何得到能运行的 option 参见上方的 guidelines for contributing] -->
   ```javascript
   option = {
       xAxis: {
           type: 'category',
           data: ['Ma', 'Mi', 'Ch', 'Wa'],
       },
       yAxis: {
           type: 'value'
       },
       // dataset: [{
       // 按行的 key-value 形式(对象数组),这是个比较常见的格式。
       //     source: [
       //         {product: 'Matcha Latte', count: 823, score: 95.8},
       //         {product: 'Milk Tea', count: 235, score: 81.4},
       //         {product: 'Cheese Cocoa', count: 1042, score: 91.2},
       //         {product: 'Walnut Brownie', count: 988, score: 76.9}
       //     ]
       // }],
       series: [{
          
           type: 'line',
           smooth: true,
           data:[
                {product: 'Matcha Latte', count: 823, score: 95.8},
                {product: 'Milk Tea', count: 235, score: 81.4},
                {product: 'Cheese Cocoa', count: 1042, score: 91.2},
                {product: 'Walnut Brownie', count: 988, score: 76.9}
               ],
           encode:{y: 1},
         
       }]
   };
   
   ```
   
   
   
   ### Other comments [其他信息]
   
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org