This commit is contained in:
duanxiaohai 2024-07-13 17:09:29 +08:00
commit 95c165b83a
1 changed files with 79 additions and 39 deletions

View File

@ -19,6 +19,7 @@ const data = reactive({
"rgba(82, 174, 255, 1)", "rgba(82, 174, 255, 1)",
], ],
}); });
const colorList = ['#ffd813', '#08daaa', '#6571fc','red'];
let datas = [ let datas = [
{ {
name: "高血压", name: "高血压",
@ -37,60 +38,99 @@ let datas = [
value: 80, value: 80,
}, },
]; ];
const colorList = ["#ffd813", "#08daaa", "#6571fc"];
const getOption = () => { const getOption = () => {
data.option = { data.option = {
// color: data.color,
title: { title: {
// text: "", //
// text: "", //
textStyle: { textStyle: {
color: "#212b43", //
fontSize: 14, //fontWeight: 'normal', color: "#fff",
fontSize: 16,
}, },
}, //
},
legend: { legend: {
bottom: "0;", itemHeight: 10,
itemWidth: 25,
icon: "rect",
orient: "vertical",
top: "center",
right: "16%",
itemGap: 30, //
textStyle: {
align: "left",
color: "#ffffff",
verticalAlign: "middle",
rich: {
name: {
width: 80,
fontSize: 16,
},
value: {
width: 30,
align: "right",
fontFamily: "Medium",
fontSize: 16,
},
rate: {
width: 20,
align: "right",
fontSize: 16,
},
},
},
data: datas,
formatter: (name) => {
if (datas.length) {
const item = datas.filter((item) => item.name === name)[0];
return `{name|${name}} {value| ${item.value}}`;
}
},
}, },
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{b}:{c}",
}, },
series: [ series: [
{ {
type: "pie", type: 'pie',
radius: [0, 100], radius: [0, 100],
center: ["50%", "40%"], center: ['50%', '40%'],
roseType: "area", roseType: 'area',
itemStyle: { itemStyle: {
color: (params) => { color: (params) => {
return colorList[params.dataIndex]; return colorList[params.dataIndex];
}, },
borderRadius: 8, borderRadius: 8,
}, // },
//
label: { label: {
show: true, show: true,
position: "outside", position: 'outside',
formatter: "{a|{b}{d}%}\n{hr|}", formatter: '{a|{b}{c}}\n{hr|}',
rich: { rich: {
hr: { hr: {
backgroundColor: "auto",
backgroundColor: 'auto',
borderRadius: 3, borderRadius: 3,
width: 1, width: 3,
height: 3, height: 3,
padding: [3, 3, 0, -12], padding: [3, 3, 0, -12],
}, },
a: { a: {
padding: [0, 1, -20, 15], padding: [-30, 15, -20, 15],
color: "auto", color: 'auto',
}, },
}, },
}, },
data: [
{ value: 200, name: "高血压" }, data: datas,
{ value: 230, name: "糖尿病" },
{ value: 198, name: "其他疾病患者" },
{ value: 80, name: "无重大疾病患者" },
],
}, },
], ],
}; };