From 3fb3c1346d5ec98c7dd0c8d268dfe2ca6faef60e Mon Sep 17 00:00:00 2001 From: duanxiaohai <1812246227@qq.com> Date: Mon, 15 Apr 2024 15:58:19 +0800 Subject: [PATCH] gx --- src/view/echarts/ylJHSY.vue | 111 ++++++++++++++++++++++++------------ src/view/echarts/ylXZZC.vue | 89 ++++++----------------------- src/view/yl.vue | 99 +++++++------------------------- 3 files changed, 114 insertions(+), 185 deletions(-) diff --git a/src/view/echarts/ylJHSY.vue b/src/view/echarts/ylJHSY.vue index 4f1d1f1..e4b4039 100644 --- a/src/view/echarts/ylJHSY.vue +++ b/src/view/echarts/ylJHSY.vue @@ -9,13 +9,40 @@ import * as echarts from "echarts"; const chart = ref(); // 创建DOM引用 -let option = { +const data = [120, 200, 150, 80, 70, 110, 130]; +const lineData = [150, 230, 224, 218, 135, 147, 260]; +const max = data.concat(lineData).reduce((pre, cur) => (pre > cur ? pre : cur), 0); //找到这个新数组中的最大值 +// 背景颜色 +const color = [ + { + type: "linear", + x: 0, + x2: 0, + y: 0, + y2: 1, + colorStops: [ + { + offset: 0, + color: "#40BDF7", + }, + { + offset: 0.5, + color: "#40BDF7", + }, + { + offset: 1, + color: "#3F82F7", + }, + ], + }, +]; +const option = { tooltip: { trigger: "axis", axisPointer: { type: "cross", label: { - backgroundColor: "#ff0000", //提示文字标题颜色 + backgroundColor: "#3F82F7", //提示文字标题颜色 }, }, }, @@ -30,69 +57,79 @@ let option = { color: "#ffffff", }, calculable: true, - color: "rgba(0, 252, 255, 1)", + // color: "rgba(0, 252, 255, 1)", + color, xAxis: [ { - // type: "category", - // scale: true, + type: "category", // name: "计划生育补贴金额/元", data: ["2019", "2020", "2021", "2022", "2023"], }, + { + type: "category", + show: false, + data: ["2019", "2020", "2021", "2022", "2023"], + }, ], yAxis: [ { type: "value", scale: true, name: "计划生育人数", - color: "rgba(255, 252, 0, 1)", + max: max, }, { type: "value", scale: true, name: "计划生育补贴金额/元", - position: "right", - max: 1200, min: 0, - boundaryGap: [0.2, 0.2] - // alignTicks: true, - // offset: 80, - // axisLine: { - // show: true, - // lineStyle: { - // color: colors[1] - // } - // }, - // axisLabel: { - // formatter: '{value} ml' - // } + max: max, + // max: 300, + // position: "right", + // boundaryGap: [0.2, 0.2] }, ], series: [ { name: "计划生育人数", + data: data, + barWidth: 20, type: "bar", - data: [2.0, 4.9, 7.0, 23.2, 25.6], - showBackground: true, - backgroundStyle: { - color: "rgba(180, 180, 180, 0.2)", - }, - itemStyle: { - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ - { offset: 0, color: "#83bff6" }, - { offset: 0.5, color: "#188df0" }, - { offset: 1, color: "#188df0" }, - ]), - }, //背景渐变 }, { name: "计划生育补贴金额", + data: lineData, type: "line", //线状图 - data: [2.6, 5.9, 9.0, 16.4, 28.7], - - showBackground: true, - backgroundStyle: { - color: "rgba(180, 180, 180, 0.2)", + }, + { + xAxisIndex: 1, + itemStyle: { + color: "rgba(180, 180, 180, 0.2)", //外阴影背景 }, + data: data.map(() => max), + barWidth: 60, //外阴影背景宽 + emphasis: { + itemStyle: { + color: { + type: "linear", + x: 0, + x2: 0, + y: 0, + y2: 1, + colorStops: [ + { + offset: 0, + color: "rgba(64, 247, 176, 0.25)", + }, + { + offset: 1, + color: "rgba(17, 34, 64, 0.25)", + }, + ], + }, + }, + }, + type: "bar", }, ], }; diff --git a/src/view/echarts/ylXZZC.vue b/src/view/echarts/ylXZZC.vue index 65372e9..8086690 100644 --- a/src/view/echarts/ylXZZC.vue +++ b/src/view/echarts/ylXZZC.vue @@ -1,5 +1,5 @@