效果展示:
代码:
//首页转速盘
export const pieSpeed = (params) => {let demoDataif (params.length !== 0) {demoData = params?.map(item => {return {title: item.title,name: item.name,value: item.value,unit: item.unit || '',pos: item.pos,rangeMax: item.rangeMax,}})} else {demoData = [{title: '左沱江螺旋桨转速',name: 'r/min',value: 80,unit: '',pos: ['25%', '50%'],rangeMax: 100},{title: '右沱江螺旋桨转速',name: 'r/min',value: 80,unit: '',pos: ['75%', '50%'],rangeMax: 100},];}let option = {backgroundColor: '#fff',series: (function () {let result = [];demoData.forEach(function (item) {result.push({name: item.name,type: 'gauge',center: item.pos,radius: '100%',startAngle: 225,endAngle: -45,min: 0,max: item.rangeMax,axisLine: {show: true,lineStyle: {width: 4,// shadowBlur: 10,color: [[0, 'transparent'],[0.05, '#fd0001'],[0.055, 'transparent'],[0.1, '#fd0001'],[0.105, 'transparent'],[0.145, '#fd0001'],[0.15, 'transparent'],[0.2, '#fd0001'],[0.205, 'transparent'],[0.245, '#0894f6'],[0.25, 'transparent'],[0.3, '#0894f6'],[0.305, 'transparent'],[0.345, '#0894f6'],[0.35, 'transparent'],[0.4, '#0894f6'],[0.405, 'transparent'],[0.445, '#0894f6'],[0.45, 'transparent'],[0.5, '#0894f6'],[0.505, 'transparent'],[0.545, '#0894f6'],[0.55, 'transparent'],[0.6, '#0894f6'],[0.605, 'transparent'],[0.645, '#0894f6'],[0.65, 'transparent'],[0.7, '#0894f6'],[0.705, 'transparent'],[0.745, '#0894f6'],[0.75, 'transparent'],[0.8, '#0894f6'],[0.805, 'transparent'],[0.845, '#fd0001'],[0.85, 'transparent'],[0.9, '#fd0001'],[0.905, 'transparent'],[0.945, '#fd0001'],[0.95, 'transparent'],[1, '#fd0001'],],},},axisTick: {show: 0,},splitLine: {show: 0,},axisLabel: {show: 0,},pointer: {show: false,},detail: {show: false,},data: [{show: false,},],}, {name: item.name,center: item.pos,type: 'gauge',radius: '90%',startAngle: 225,endAngle: -45,min: 0,max: item.rangeMax,axisLine: {show: true,lineStyle: {width: 23,color: [[item.value / parseInt(item.rangeMax / 3),// item.value,new _echarts.graphic.LinearGradient(0, 1, 1, 0,[{offset: 0,color: 'rgba(67, 122, 203, 0.02)',},{offset: 0.3,color: 'RGBA(209, 226, 254, 0.23)',},{offset: 1,color: 'RGBA(209, 226, 254, 1)',},]),],[1, 'rgba(255,255,255,.0)'],],},},axisTick: {show: 0,},splitLine: {show: 0,},axisLabel: {show: 0,// show: true,// splitNumber: 30,// distance: 40,},pointer: {show: true,length: '100%',},detail: {show: true,offsetCenter: [0, '-3%'],textStyle: {fontSize: 14,fontWeight: 600,lineHeight: 30,color: 'RGBA(0, 203, 224, 1)',},formatter: [(item.title || '标题'), (''), '{value}', '{name|' +item.name + '}'].join('\n'),rich: {name: {fontSize: 12,lineHeight: 3,color: '#000',fontWeight: '300',},},},itemStyle: {color: 'RGBA(68, 122, 203, 1)',borderColor: 'RGBA(157, 186, 228, 1)',shadowColor: 'RGBA(222, 231, 246, 1)',shadowBlur: 10,shadowOffsetX: 2,shadowOffsetY: 2},data: [{value: item.value,},],anchor: {show: true,showAbove: true,size: 16,itemStyle: {color: 'RGBA(66, 122, 203, 1)',},},markPoint: {data: [{x: "25%",y: "50%",symbol: 'circle',symbolSize: 12,itemStyle: {color: '#fff'},}, {x: "75%",y: "50%",symbol: 'circle',symbolSize: 12,itemStyle: {color: "#fff"},}]},}, {type: 'gauge',radius: '90%',center: item.pos,splitNumber: 10,min: 0,max: item.rangeMax,splitNumber: 4,startAngle: 225,endAngle: -45,axisLine: {show: true,lineStyle: {width: 1,color: [[1,new _echarts.graphic.LinearGradient(0, 0, 1, 0,[{offset: 0,color: '#747474',},{offset: 1,color: 'red',},]),],],},},axisLabel: {distance: 1,textStyle: {color: '#000',fontSize: '12',},},axisTick: {show: true,distance: 0,},splitLine: {show: true,length: 10,distance: 0,lineStyle: {color: '#ccc',},},pointer: {show: 0,},detail: {show: 0,},});});return result;})(),};let option2 = {backgroundColor: '#fff',series: (function () {var result = [];demoData.forEach(function (item) {result.push({name: item.name,type: 'gauge',center: item.pos,radius: '60%',startAngle: 225,endAngle: -45,min: 0,max: 1,axisLine: {show: true,lineStyle: {width: 4,shadowBlur: 10,color: [[0, 'transparent'],[0.05, '#fd0001'],[0.055, 'transparent'],[0.1, '#fd0001'],[0.105, 'transparent'],[0.145, '#fd0001'],[0.15, 'transparent'],[0.2, '#fd0001'],[0.205, 'transparent'],[0.245, '#0894f6'],[0.25, 'transparent'],[0.3, '#0894f6'],[0.305, 'transparent'],[0.345, '#0894f6'],[0.35, 'transparent'],[0.4, '#0894f6'],[0.405, 'transparent'],[0.445, '#0894f6'],[0.45, 'transparent'],[0.5, '#0894f6'],[0.505, 'transparent'],[0.545, '#0894f6'],[0.55, 'transparent'],[0.6, '#0894f6'],[0.605, 'transparent'],[0.645, '#0894f6'],[0.65, 'transparent'],[0.7, '#0894f6'],[0.705, 'transparent'],[0.745, '#0894f6'],[0.75, 'transparent'],[0.8, '#0894f6'],[0.805, 'transparent'],[0.845, '#fd0001'],[0.85, 'transparent'],[0.9, '#fd0001'],[0.905, 'transparent'],[0.945, '#fd0001'],[0.95, 'transparent'],[1, '#fd0001'],],},},axisTick: {show: 0,},splitLine: {show: 0,},axisLabel: {show: 0,},pointer: {show: false,},detail: {show: false,},data: [{show: false,},],}, {name: item.name,center: item.pos,type: 'gauge',radius: '50%',startAngle: 225,endAngle: -45,min: 0,max: item.rangeMax,axisLine: {show: true,lineStyle: {width: 50,color: [[item.value / 100,new _echarts.graphic.LinearGradient(0, 1, 1, 0,[{offset: 0,color: 'rgba(67, 122, 203, 0.02)',},{offset: 0.3,color: 'RGBA(209, 226, 254, 0.23)',},{offset: 1,color: 'rgba(209, 226, 254, 1)',},]),],[1, 'rgba(255,255,255,.0)'],],},},axisTick: {show: 0,},splitLine: {show: 0,},axisLabel: {show: 0,},pointer: {show: true,length: '100%',},detail: {show: true,offsetCenter: [0, '20%'],textStyle: {fontSize: 24,color: 'RGBA(0, 203, 224, 1)',},formatter: [(item.title || '标题'), (' '), (' '), '{value}' + (item.unit || ''), '{name|' + item.name + '}'].join('\n'),rich: {name: {fontSize: 20,lineHeight: 30,color: '#000',fontWeight: '300',},},},itemStyle: {color: 'RGBA(68, 122, 203, 1)',// borderColor: 'RGBA(157, 186, 228, 1)',// shadowColor: 'RGBA(222, 231, 246, 1)',// shadowBlur: 10,// shadowOffsetX: 2,// shadowOffsetY: 2},data: [{value: item.value,},],anchor: {show: true,showAbove: true,size: 22,itemStyle: {color: 'RGBA(102, 147, 212, 1)',borderWidth: '1px',borderColor: 'RGBA(157, 186, 228, 1)',},},markPoint: {data: [{x: "75%",y: "50%",symbol: 'circle',symbolSize: 24,itemStyle: {color: 'RGBA(102, 147, 212, 1)'},}, {x: "75%",y: "50%",symbol: 'circle',symbolSize: 18,itemStyle: {color: "#fff"},}]},}, {type: 'gauge',radius: '56%',center: item.pos,splitNumber: 10,min: 0,max: item.rangeMax,startAngle: 225,endAngle: -45,axisLine: {show: true,lineStyle: {width: 3,color: [[1,new _echarts.graphic.LinearGradient(0, 0, 1, 0,[{offset: 0,color: '#747474',},{offset: 1,color: '#747474',},]),],],},},axisLabel: {distance: 6,textStyle: {color: '#000',fontSize: '14',},},splitLine: {show: true,length: 16,lineStyle: {color: '#ccc',},},pointer: {show: 0,},detail: {show: 0,},});});return result;})(),}return option
}