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 2019/05/09 09:02:12 UTC

[GitHub] [incubator-echarts] MousseWang opened a new issue #10429: 通过tooltip中的formatter中更改setOption配置,影响tooltip显示

MousseWang opened a new issue #10429: 通过tooltip中的formatter中更改setOption配置,影响tooltip显示
URL: https://github.com/apache/incubator-echarts/issues/10429
 
 
   ### Version
   4.2.1
   
   ### Steps to reproduce
   ```
   tooltip: {
   	...
   	formatter: function(param) {
   	  getLen(myChart,param)
   	  var arr = []
   	  param.forEach(item => {
   		if(item.seriesName === 'Kline'){
   		  arr.push(item.name   '<br />');
   		  ...
   		}
   	  })
   	  return arr.join('')
   	},
   	position: function (pos, params, el, elRect, size) {
   		var obj = {top: 60};
   		obj[['left', 'right'][ (pos[0] < size.viewSize[0] / 2)]] = 60;
   		return obj;
   	}
    },
   ```
   
   ```
   function getLen(myChart,param){
         let data = {
           "MA10": '',
           ...
         }
         param.forEach(item => {
           item.seriesName === "MA10" ? data.MA10 = item.data : null;
           ...
         })
         myChart.setOption({
           legend:[
             {
               formatter: function (name) {
                 return `${name}:${data.MA10.toFixed(2)}`;
               },
             },
             ...
         ]
         })
       }
   ```
   
   ### What is expected?
   图例数据动态显示,tooltip正常
   
   ### What is actually happening?
   图例数据动态显示,tooltip只有在鼠标放置在烛型图上时出现,在放置在画布其他位置时不出现
   
   ---
   业务场景: 需要在图例中动态显示当前鼠标位置的数据
   
   我的解决方案: 在tooltip中的formatter中更改setOption配置,动态修改图例数据
   
   <!-- 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


With regards,
Apache Git Services

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