This commit is contained in:
duanxiaohai 2024-06-17 09:58:05 +08:00
parent f446f1edb3
commit a3eb85e5c7
2 changed files with 77 additions and 132 deletions

View File

@ -44,12 +44,7 @@
<span> {{ item.name }}</span> <span> {{ item.name }}</span>
</div> </div>
</div> </div>
<eP2 <eP2 :list="data.DataViewing" :year="data.leftCenterYear"></eP2>
:list="data.DataViewing"
:list1="data.leftCenter3"
:list2="data.leftCenter4"
:year="data.leftCenterYear"
></eP2>
</div> </div>
</div> </div>
</div> </div>
@ -170,38 +165,38 @@ const data = reactive({
{ {
name: "医保支出万元以上", name: "医保支出万元以上",
value: "11112", value: "11112",
show: false, show: true,
data: ["100", "120", "199", "133", "210"], // data: ["100", "120", "199", "133", "210"], //
}, },
{ {
name: "大病住院", name: "大病住院",
value: "120", value: "120",
show: false, show: false,
data: ["100", "120", "199", "133", "210"], // data: ["100", "0", "199", "133", "210"], //
}, },
{ {
name: "高血压", name: "高血压",
value: "2345", value: "2345",
show: false, show: false,
data: ["100", "120", "199", "133", "210"], // data: ["100", "10", "199", "133", "210"], //
}, },
{ {
name: "糖尿病", name: "糖尿病",
value: "1241", value: "1241",
show: false, show: false,
data: ["100", "120", "199", "133", "210"], //尿 data: ["100", "120", "19", "133", "210"], //尿
}, },
{ {
name: "高血脂", name: "高血脂",
value: "1414", value: "1414",
show: false, show: false,
data: ["100", "120", "199", "133", "210"], // data: ["100", "120", "199", "13", "210"], //
}, },
{ {
name: "高血糖", name: "高血糖",
value: "2355", value: "2355",
show: false, show: false,
data: ["100", "120", "199", "133", "210"], // data: ["100", "120", "199", "133", "10"], //
}, },
{ {
name: "残疾", name: "残疾",
@ -228,11 +223,16 @@ const data = reactive({
data: ["100", "120", "199", "133", "210"], // data: ["100", "120", "199", "133", "210"], //
}, },
], ],
DataViewing: {}, // DataViewing: [
leftCenter1: ["100", "120", "199", "133", "210"], // {
leftCenter3: ["100", "80", "199", "133", "210"], // name: "医保支出万元以上",
leftCenter4: ["100", "120", "199", "133", "210"], //尿 data: ["100", "120", "199", "133", "210"], //
},
], //
leftCenterYear: ["2019", "2020", "2021", "2022", "2023"], // leftCenterYear: ["2019", "2020", "2021", "2022", "2023"], //
// leftCenter1: ["100", "120", "199", "133", "210"], //
// leftCenter3: ["100", "80", "199", "133", "210"], //
// leftCenter4: ["100", "120", "199", "133", "210"], //尿
zccs1: ["图书馆", "交通出行", "景区"], // zccs1: ["图书馆", "交通出行", "景区"], //
zccs2: ["100", "130", "220"], // zccs2: ["100", "130", "220"], //

View File

@ -8,7 +8,7 @@ import { onBeforeMount, reactive, ref, watch } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
const chart = ref(); // DOM const chart = ref(); // DOM
const clear = ref(false);
const props = defineProps({ const props = defineProps({
list: { list: {
type: Array, type: Array,
@ -35,7 +35,17 @@ const props = defineProps({
}, },
}, },
}); });
const sers = ref([
{
name: "背景",
type: "bar",
data: [],
showBackground: true,
backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)",
},
},
]);
const data = reactive({ const data = reactive({
list: [], list: [],
list1: [], list1: [],
@ -44,6 +54,17 @@ const data = reactive({
option: {}, option: {},
bg: [], bg: [],
name: [], name: [],
ser: [],
len: {
data: [],
top: "0%",
right: "5%",
textStyle: {
fontSize: 16,
color: "#ffffff",
},
},
formatter: "{b0}<br />",
}); });
const getOption = () => { const getOption = () => {
@ -51,19 +72,11 @@ const getOption = () => {
tooltip: { tooltip: {
trigger: "axis", trigger: "axis",
padding: [20, 10, 20, 10], padding: [20, 10, 20, 10],
formatter: "{b0}<br />{a1}:{c1} <br />{a2}:{c2}", formatter: data.formatter,
},
legend: {
data: data.name,
top: "5%",
right: "10%",
textStyle: {
fontSize: 16,
color: "#ffffff",
},
}, },
legend: data.len,
grid: { grid: {
top: "25%", top: "35%",
left: "6%", left: "6%",
right: "6%", right: "6%",
bottom: "3%", bottom: "3%",
@ -155,102 +168,27 @@ const getOption = () => {
}, },
}, },
], ],
series: [ series: data.ser,
{
name: "背景",
type: "bar",
data: data.bg,
showBackground: true,
backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)",
},
},
{
yAxisIndex: 0,
name: "大病住院",
type: "line",
symbol: "emptyCircle",
symbolSize: 10,
itemStyle: {
borderColor: "#2468FF",
borderWidth: 1,
color: "#2468FF",
},
label: {
show: true,
color: "#2468FF",
formatter: function (data) {
return data.value;
},
},
data: data.list1,
},
{
yAxisIndex: 1,
name: "糖尿病",
type: "line",
symbol: "emptyCircle",
symbolSize: 10,
itemStyle: {
borderColor: " #00FCFF ",
borderWidth: 1,
color: "#00FCFF ",
},
label: {
show: true,
color: "#00FCFF",
formatter: function (data) {
return data.value;
},
},
data: data.list2,
},
],
}; };
}; };
const setChart = () => { const setChart = () => {
var myChart = echarts.init(chart.value); var myChart = echarts.init(chart.value);
if (clear.value) {
myChart.clear();
}
myChart.setOption(data.option); myChart.setOption(data.option);
}; };
// const setChart1 = () => {
// if (Object.keys(data.list).length !== 0) {
// data.list1 = [];
// data.list2 = [];
// data.list.data.forEach((item) => {
// // data.list1.push(item.jzrs); //
// // data.list2.push(item.jzje); //
// data.option.series.push();
// });
// data.name = [];
// data.list.forEach((item) => {
// data.name.push(item.name); //
// });
// console.log(data.list, data.name, "");
// }
// };
const setChart1 = () => { const setChart1 = () => {
data.name = []; data.ser.length = 0;
if (Object.keys(data.list).length !== 0) { sers.value.forEach((item) => {
data.list1 = []; data.ser.push(item);
data.list2 = [];
// data.name = [];
data.option.series = [];
// Define background series
data.option.series.push({
name: "背景",
type: "bar",
data: data.bg,
showBackground: true,
backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)",
},
}); });
if (data.name.length > 0) {
data.list.forEach((item) => { data.list.forEach((item) => {
// console.log(item, "111"); data.ser.push({
data.option.series.push({
yAxisIndex: 0, yAxisIndex: 0,
name: item.name, name: item.name,
type: "line", type: "line",
@ -268,40 +206,47 @@ const setChart1 = () => {
return data.value; return data.value;
}, },
}, },
data: [item.data],
});
});
data.list.forEach((item) => {
data.name.push(item.name); //
});
console.log(data.list, data.name, "数据名"); data: item.data,
});
});
} }
console.log("监听", data.ser);
console.log("监听1", sers.value);
}; };
// //
watch( watch(
() => props.list, () => props.list,
(newVal, oldVal) => { (newVal, oldVal) => {
setTimeout(() => { if (newVal.length < oldVal.length) {
clear.value = true;
} else {
clear.value = false;
}
data.list = newVal; data.list = newVal;
// console.log("1", data.list); data.name = props.list.map((item) => item.name);
getOption(); data.len.data = data.name;
sers.value[0].data = data.year.map((item) => 0);
data.formatter = "{b0}<br />";
if (data.name.length > 0) {
for (let i = 1; i <= data.name.length; i++) {
let s1 = `{a${i}}:{c${i}}<br />`;
data.formatter += s1;
}
}
setChart1(); setChart1();
getOption();
setChart(); setChart();
}, 600);
} }
); );
// 使 // 使
onBeforeMount(() => { onBeforeMount(() => {
setTimeout(() => { setTimeout(() => {
data.list = props.list; data.list = props.list;
data.list1 = props.list1;
data.list2 = props.list2;
data.year = props.year; data.year = props.year;
data.year.forEach(() => { sers.value[0].data = data.year.map((item) => 0);
data.bg.push(0);
});
setChart1(); setChart1();
getOption(); getOption();
setChart(); setChart();