可视化

编程入门 行业动态 更新时间:2024-10-27 21:10:12

可视化

可视化

  • echarts模板来源

📚改编点

🐇基本样式

  • 去掉legend、label:show: false
  • 背景透明: backgroundColor: "transparent"
  • 去除功能标签
  • 添加载入动态
    animationEasing: 'elasticOut',
    animationDelay: function (idx) {return Math.random() * 2000;}
    
  • 统一设置颜色
    color: {type: "linear",x: 0,y: 0,x2: 0,y2: 1,colorStops: [{offset: 0, color: '#e6534c'},{offset: 1, color: '#fff'},],global: false
    }
    

🐇添加中心文字循播放

  • 首先给定graphic区域放文字
    var graphic = [{type: 'text',left: 'center',top: 'center',style: {text: getPieText(pieData, currentIndex),textAlign: 'center',fill: '#000',fontSize: 18,fontWeight: 'bold',}
    }];
    
  • 获取文字,全称太长取前两个字(关注黑龙江!!)
    function getPieText(data, index) {var name = data[index].name.substring(0, 2);if(data[index].name == '黑龙江省'){name = data[index].name.substring(0, 3);}return name + ((data[index].value / getTotalValue(data) * 100).toFixed(2)) + '%';
    }function getTotalValue(data) {return data.reduce((total, current) => {return total + current.value;}, 0);
    }
    
  • 每次更新
    function updateGraphic() {currentIndex = (currentIndex + 1) % pieData.length;myChart.setOption({graphic: [{type: 'text',left: 'center',top: 'center',style: {text: getPieText(pieData, currentIndex),textAlign: 'center',fill: '#000',fontSize: 18,fontWeight: 'bold',}}]});
    }
    
  • 设置更新频率:setInterval(updateGraphic, 1500);

🐇添加中间文字对应图形变色

function updateGraphic() {currentIndex = (currentIndex + 1) % pieData.length;myChart.setOption({graphic: [{type: 'text',left: 'center',top: 'center',style: {text: getPieText(pieData, currentIndex),textAlign: 'center',fill: '#000',fontSize: 18,fontWeight: 'bold',}}],series: [{selected: currentIndex,itemStyle: {color: function(params) {return (params.dataIndex === currentIndex) ? '#AC2619' : {type: "linear",x: 0,y: 0,x2: 0,y2: 1,colorStops: [{ offset: 0, color: '#e6534c' },{ offset: 1, color: '#fff' }],global: false}}}}]});}

📚final


  • 整合地图,3d词云and饼图

更多推荐

可视化

本文发布于:2023-11-15 09:16:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1597292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!