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/08/06 07:48:49 UTC

[GitHub] yangqianqq opened a new issue #8819: 自定义echart的图形,polyline设置为平滑曲线,相同数值时候曲线还有弯曲。

yangqianqq opened a new issue #8819: 自定义echart的图形,polyline设置为平滑曲线,相同数值时候曲线还有弯曲。
URL: https://github.com/apache/incubator-echarts/issues/8819
 
 
   自定义echart的图形,polyline设置为平滑曲线,相同数值时候曲线还有弯曲。
   但是直接使用type为line不存在这个问题
   
   
   配置项一下代码全部粘贴
   
   
   var useData =  [0,2,0,6,0,0]
   
   
   
   function renderAverageItem(param, api) {
    
        var oneStep = api.coord([0, 0]);
        var TwoStep = api.coord([1,0])
   
      var points = echarts.util.map(useData, function (entry, index) {
           var point = api.coord( [index,entry]);
           return [point[0] + (TwoStep[0] - oneStep[0]) / 2 , point[1]];
       });
       
   
       return {
           type: 'polyline',
           shape: {
               points:points,
               smooth:0.4
           },
           style: api.style({
               fill: null,
               stroke: "#1890ff",
               
               lineWidth: 1.5,
           })
       };
   }
   
   option = {
       xAxis: {
           type: 'category',
           data: ['', '1', '2', '3', '4', '5', ''],
           boundaryGap:false
       },
       yAxis: {
           type: 'value'
       },
       
       series: [{
           type: 'custom',
           name: 'trend',
           renderItem: renderAverageItem,
           itemStyle: {
               normal: {
                   borderWidth: 2
               }
           },
           encode: {
               x: 0,
               y: echarts.util.map(useData, function (entry, index) {
                   return index + 1;
               })
           },
           data: useData,
           z: 100
       }]
   };
   
   
   

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