let myChart = this.$echarts.init(document.getElementById("yibiao1"));
let JbColor = new this.$echarts.graphic.LinearGradient(1, 1, 1, 0, [
{ offset: 0.1, color: "#FDE73B" },
{ offset: 0.4, color: "#00D21A" },
{ offset: 1, color: "#00D2EF" },
]);
let option = {
series: [
{
type: "gauge",
min: 0,
max: maxData,
splitNumber: 4,
radius: "85%",
axisLine: {
//仪表盘圈的样式
lineStyle: {
color: JbColor,
width: 8, //圆环宽度(坐标轴宽度)
},
},
pointer: {
width: 2,
itemStyle: {
color: "auto",
},
},
axisTick: {
//坐标轴小标记
show: false,
distance: 30,
length: 1,
lineStyle: {
color: "#ffffff",
width: 1,
},
},
splitLine: {
// 分隔线
length: 0, // 属性length控制线长
lineStyle: {
color: "auto",
},
},
axisLabel: {
//刻度文字
color: "#00DBF5", //文字颜色
fontSize: 12,
padding: 0,
textShadowBlur: 20,
textShadowOffsetX: 1,
textShadowOffsetY: 1,
textShadowColor: "#fff",
distance: 15,
},
detail: {
//其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: "bolder",
shadowBlur: 5,
shadowColor: "#00A0E9",
shadowOffsetX: 0,
shadowOffsetY: 1,
textShadowOffsetX: 0,
textShadowOffsetY: 1,
fontFamily: "Arial",
fontSize: 25,
width: 20,
height: 1,
color: "#62D4FB",
rich: {},
},
data: [
{
value: realData,
},
],
},
],
};
if (realData >= maxData) {
option.series[0].axisLine.lineStyle.color = [
[0.0, "lime"],
[maxData / realData, JbColor],
[1 + realData / maxData, "#ff0000"],
[1, option.series[0].axisLine.lineStyle.color],
];
} else {
option.series[0].axisLine.lineStyle.color = [
[0.0, "lime"],
[1, JbColor],
];
}
myChart.setOption(option);
|