当前位置:   article > 正文

echarts -环形图高亮时中间文字设置(三)_echart 高亮的时候显示的字

echart 高亮的时候显示的字
  1. var myChart4 = null;
  2. var currentIndex = -1;
  3. var chart4Interval;
  4. var data = [{"areaId":null,"areaName":"xxxx轮胎有限公司","deviceCode":"dht5084416002","deviceName":"5-1-MN002","alarmCount":"1385","allCount":"20146","alarmRate":"6.87"},{"areaId":null,"areaName":"xxxx化工公司","deviceCode":"ccc5087717013","deviceName":"废气总排口","alarmCount":"1244","allCount":"14928","alarmRate":"8.33"}];
  5. function deviceAlarmRateOfTotal(data){
  6. if(myChart4!=null){
  7. myChart4.dispatchAction({
  8. type: 'downplay',
  9. seriesIndex: 0,
  10. dataIndex: currentIndex
  11. });
  12. myChart4.dispatchAction({
  13. type: 'hideTip'
  14. });
  15. }
  16. currentIndex = -1;
  17. if(chart4Interval!=null){
  18. clearInterval( chart4Interval);
  19. }
  20. myChart4 = echarts.init(document.getElementById("chart_msc4"));
  21. var arry = [];
  22. for(var i=0;i<data.length;i++){
  23. arry[i] = {value:data[i].alarmCount, name:data[i].deviceName};
  24. }
  25. var option = {
  26. tooltip: {
  27. trigger: 'item',
  28. formatter: function(params,ticket,calback){
  29. var str = '<div style="text-align:center;width:5em;color:#fff;background:transparent;border-color:#0e335f;margin:-5px; transition: all 2s;z-index:100000000;" id="toolTipBox" >'+
  30. '<p style="font-size:size*1.2;margin:0px;font-weight:bold;">'+params.percent+'%</p>'+
  31. '<p style="font-size:size*0.8;margin:0px 0px 0px 0px; color:#fff">'+params.name+'</p></div>';
  32. return str;
  33. },
  34. position:function(point,params,dom,rect,size){
  35. var marginW = Math.ceil(size.contentSize[0]/2);
  36. var marginH = Math.ceil(size.contentSize[1]/2);
  37. dom.style.marginLeft = "-" + marginW + 'px';
  38. dom.style.marginTop = '-' + marginH + "px";
  39. return ['50%','50%'];
  40. },
  41. alwaysShowContent:true,
  42. backgroundColor:"transparent",
  43. textStyle:{
  44. fontSize:size,
  45. color:'#0e335f'
  46. }
  47. },
  48. color:['#234591','#90ac45',"#24feb4",'#1bb2d8','#066660','#88b0bb',"#2b65bc","#75a0e1"],
  49. series: [
  50. {
  51. name: '设备报警占比',
  52. type: 'pie',
  53. center: ['50%', '50%'], // 饼图的圆心坐标
  54. radius: ['70%', '80%'],
  55. avoidLabelOverlap: false,
  56. label: {
  57. normal: {
  58. show: false,
  59. position: 'center'
  60. },
  61. emphasis: {
  62. show: false,
  63. textStyle: {
  64. fontSize: 10,
  65. color:"#0e335f"
  66. }
  67. }
  68. },
  69. labelLine: {
  70. normal: {
  71. show: false
  72. }
  73. },
  74. data:arry.slice(0,15)
  75. }
  76. ]
  77. };
  78. myChart4.setOption(option,true);
  79. chart4Interval = setInterval(function(){
  80. var dataLength= option.series[0].data.length;
  81. // 取消之前高亮的图形
  82. myChart4.dispatchAction({
  83. type: 'downplay',
  84. seriesIndex: 0,
  85. dataIndex: currentIndex
  86. });
  87. currentIndex = (currentIndex + 1) % dataLength;
  88. // 高亮当前图形
  89. myChart4.dispatchAction({
  90. type: 'highlight',
  91. seriesIndex: 0,
  92. dataIndex: currentIndex
  93. });
  94. // 显示 tooltip
  95. myChart4.dispatchAction({
  96. type: 'showTip',
  97. seriesIndex: 0,
  98. dataIndex: currentIndex
  99. });
  100. if(currentIndex>dataLength){
  101. currentIndex = -1;
  102. }
  103. $("#toolTipBox").animate({},function(){
  104. $("#toolTipBox").css({'height':'38px','transform':'rotate(360deg)'});
  105. });
  106. }, 5000);
  107. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/105473
推荐阅读