網(wǎng)站建設(shè)規(guī)模與類別蘇州百度推廣排名優(yōu)化
開發(fā)的項目中需要實現(xiàn)這樣一個水波圖,例如下圖

在echarts官網(wǎng)中找了很久沒找到,后面是在Echarts社區(qū)中找到的,實現(xiàn)了大部分的樣式,但是還有一些數(shù)據(jù)的展示沒有實現(xiàn)。水波圖的數(shù)值展示是默認整數(shù)百分比,我的需求是需要保留兩位小數(shù)。
先展示一下在社區(qū)中找到的水波圖代碼如下:
option = {backgroundColor: "#0e2147",title: {show: true,text: '違規(guī)項',x: '50%',y: '60%',z: 10,textAlign: 'center',textStyle: {color: '#ffffff',fontSize: 68,fontWeight: 500},},series: [{name: '違規(guī)項',type: 'liquidFill',radius: '60%',center: ['50%', '45%'],data: [70/100],label:{normal:{textStyle:{color: '#ffffff',fontSize: 68,}}},color: ['#4366f3'],backgroundStyle: {color: 'rgba(39,115,229,0.12)'},outline: {borderDistance: 0,itemStyle: {borderWidth: 5,borderColor: 'rgba(49,102,255,0.5)',}},// amplitude: 0,}]
};
發(fā)現(xiàn)水波圖的類型是“liquidFill”,在官網(wǎng)中沒有找到這個類型,后面發(fā)現(xiàn)是需要單獨封裝的類型,需要單獨下載安裝包。
我安裝的依賴版本(水波圖的類型應(yīng)該是在echarts 5版本支持,小伙伴們使用時注意版本):
echarts:5.2.2
echarts-liquidfill:3.1.0
主要修改的代碼是series里面的data控制數(shù)據(jù)展示和series里面的color控制水波的顏色漸變
option = {backgroundColor: "#0e2147", // 背景顏色title: {show: true,text: '水波圖', // 標題名字x: '50%',y: '60%',z: 10,textAlign: 'center', // 文字位置textStyle: { // 文字樣式設(shè)置color: '#ffffff',fontSize: 50,fontWeight: 500},},series: [{name: '水波圖',type: 'liquidFill',radius: '60%',center: ['50%', '45%'],data: [{value: [55.2 / 100],label: {normal: {formatter: `${55.2}%`,show: true,}}}],label:{normal:{textStyle:{ // 數(shù)值樣式設(shè)置color: '#ffffff',fontSize: 60,}}},color: [{type: 'linear',x: 0,y: 1,x2: 0,y2: 0,colorStops: [ // 水波顏色漸變{offset: 1,color: ['rgba(11,175,202,1)'], // 0% 處的顏色},{offset: 0,color: ['rgba(0,145,255,1)'], // 100% 處的顏色}], // 水波紋顏色}],backgroundStyle: {color: 'rgba(39,115,229,0.12)'},outline: {borderDistance: 0,itemStyle: {borderWidth: 5, // 邊 寬度borderColor: 'rgba(49,102,255,0.5)',}},}]
};
以上是我遇到的問題,簡單記錄一下(雖然...但是沒有找到echarts的全部類型,官網(wǎng)中的只是一部分),歡迎各位小伙伴來交流~
代碼參考echarts社區(qū):https://www.isqqw.com/viewer?id=17830