Merge branch 'main' of git.zdool.com:xs/ggfwjsc

This commit is contained in:
姚宇浩 2024-04-22 09:32:44 +08:00
commit e3e7c4e775
3 changed files with 247 additions and 114 deletions

View File

@ -8,7 +8,7 @@ import * as echarts from "echarts";
const chart = ref(); // DOM
// const data = [150, 230, 224, 218, 135, 147];
const data1 = ["2019年", "2020年", "2021年", "2022年", "2023年", "2024年"];
const data1 = ["中职", "高中", "初中", "小学", "幼儿园", "特殊教育"];
const data2 = [
"10000人",
"14000人",
@ -56,7 +56,6 @@ const option = {
axisTick: {
show: false, //
},
// data: ["2019", "2019", "2019", "2019", "2019", "2019", "2019"],
},
],
yAxis: [
@ -127,7 +126,7 @@ const option = {
{
type: "bar",
data: newData2.map(() => Math.max(...newData2) * 1.02), //
barWidth: 6, //
barWidth: 8, //
silent: true, //
itemStyle: {
normal: {
@ -145,7 +144,7 @@ const option = {
{
type: "bar",
data: newData2,
barWidth: 5, //
barWidth: 7, //
barGap: -1.1 /*多个并排柱子设置柱子之间的间距*/,
itemStyle: {
normal: {
@ -177,9 +176,9 @@ const option = {
height: 8,
borderRadius: 1000,
color: "rgba(0,0,0,0)",
backgroundColor: "rgba(0, 230, 255, 1)",
shadowColor: "#00E6FF",
position: ["99%", -1.5],
backgroundColor: "rgba(0, 230, 255, 1)",
position: ["99%", -0.4],
shadowBlur: 6,
},
},

View File

@ -168,11 +168,11 @@ const option = {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(142, 187, 255, 1)",
color: "rgba(255, 243, 119, 1)",
},
{
offset: 1,
color: "rgba(142, 187, 255, 0.20)",
color: "rgba(255, 242, 142, 0.20)",
},
]),
},

View File

@ -1,80 +1,106 @@
<template>
<div ref="chart" style="width: 100%; height: 300px"></div>
<div ref="chart" style="width: 100%; height: 330px"></div>
</template>
<script setup>
import { onMounted, reactive, ref } from "vue";
// echarts
import * as echarts from "echarts";
const chart = ref(); // DOM
// const data = [150, 230, 224, 218, 135, 147];
const data1 = ["2019年", "2020年", "2021年", "2022年", "2023年", "2024年"];
const data2 = [
"10000人",
"14000人",
"23000人",
"10000人",
"13200人",
"10000人",
];
const newData2 = data2.map((item) => parseInt(item.replace("人", "")));
const newMaxNumber = Math.max(...newData2) * 1.05;
const option = {
grid: {
top: "6%",
left: "9%",
right: "10%",
bottom: "0%",
containLabel: false, //---grid
const data = [120, 200, 50, 80, 70];
const lineData = [150, 230, 24, 218, 135];
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: "rgba(142, 187, 255, 1)",
},
{
offset: 0.5,
color: "rgba(142, 187, 255, 0.5)",
},
{
offset: 1,
color: "rgba(142, 187, 255, 0.20)",
},
],
},
];
const option = {
color,
calculable: true,
tooltip: {
show: true, //---,true
trigger: "axis",
formatter: "{b0}:{c0}" + "人",
formatter: "{b0}<br/> {a1}:{c0}<br/>{a2}:{c1}",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#3F82F7", //
},
},
},
legend: {
data: ["总救助金额", "总救助人数"],
top: "8%",
bottom: "9%",
textStyle: {
fontSize: 12,
color: "#ffffff", //
},
},
grid: {
left: "6%",
right: "9%",
bottom: "7%",
containLabel: true,
color: "#ffffff",
},
xAxis: [
{
type: "value",
scale: false,
max: newMaxNumber,
type: "category",
axisLabel: {
//线
show: false,
//
textStyle: {
color: "#ffffff",
},
},
axisLine: {
//y线
show: false, // x线
},
splitLine: {
show: false, //---grid 线
},
axisTick: {
show: false, //
},
// data: ["2019", "2019", "2019", "2019", "2019", "2019", "2019"],
data: ["2019", "2020", "2021", "2022", "2023"],
},
{
type: "category",
show: false,
data: ["2019", "2020", "2021", "2022", "2023"],
},
],
yAxis: [
{
type: "category",
type: "value",
scale: true,
// name: "/",
// max: data.length,
name: "救助人数",
max: max,
splitLine: {
//线
show: false,
lineStyle: {
color: "#ffffff",
width: 1,
},
},
axisTick: {
show: false, //
},
axisLabel: {
//y
textStyle: {
@ -82,100 +108,208 @@ const option = {
},
},
axisLine: {
//线
//y线
show: false,
// lineStyle: {
// color: "#ffffff",
// width: 1,
// type: "solid",
// },
lineStyle: {
color: "#ffffff",
width: 1,
type: "solid",
},
},
data: data1,
},
{
type: "category",
show: true,
position: "right",
axisLine: {
//--- 线
show: false, // 线
type: "value",
scale: true,
min: 0,
max: max,
name: "救助金额/万",
splitLine: {
show: false,
lineStyle: {
color: "rgba(226, 226, 226, 0.3)",
width: 1,
},
},
axisLabel: {
//---
//y
textStyle: {
color: "#ffffff",
},
},
axisTick: {
show: false, //
axisLine: {
//y线
show: false,
lineStyle: {
color: "#ffffff",
width: 1,
type: "solid",
},
},
data: data2,
},
],
series: [
//
{
type: "bar",
data: newData2.map(() => Math.max(...newData2)* 1.05), //
// barGap: 0 /**/,
yAxisIndex: 1,
barWidth: 30, //
silent: true, //
name: "",
type: "pictorialBar",
symbolSize: [20, 5], //
symbolOffset: [0, 2], //
z: 12,
symbol: 'circle', //
itemStyle: {
color: "rgba(0, 230, 255, 0.1)", //
color: "rgba(38, 191, 254, 1)",
// color: "red",
},
data: data,
},
//
{
name: "总救助金额",
data: lineData,
type: "line", //线
stack: "Total",
symbol: "emptyCircle",
symbolSize: 10,
itemStyle: {
borderWidth: 1,
color: "rgba(36, 104, 255, 1)",
borderColor: "#00FCFF",
},
},
//
{
name: "总救助人数",
data: data,
barWidth: 20,
type: "bar",
data: newData2.map(() => Math.max(...newData2)* 1.05), //
barWidth: 6, //
silent: true, //
itemStyle: {
color: "rgba(94, 178, 188, 0.1)", //
// borderColor: "#00FCFF",
// borderWidth: 1,
// color: "#00FCFF",
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: "rgba(0, 204, 255, 1)",
},
{
offset: 1,
color: "rgba(0, 255, 213, 1)",
},
]),
},
},
//
{
type: "bar",
data: newData2,
barWidth: 5, //
barGap: -1.1 /*多个并排柱子设置柱子之间的间距*/,
xAxisIndex: 1,
itemStyle: {
normal: {
color: function (params) {
var colorList = [
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: "rgba(0, 230, 255, 0)" },
{ offset: 0.5, color: "rgba(0, 230, 255, 0.5)" },
{ offset: 1, color: "rgba(0, 230, 255, 1)" },
]),
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: "rgba(0, 255, 208,0)" },
{ offset: 0.5, color: "rgba(0, 255, 208,0.5)" },
{ offset: 1, color: "rgba(0, 255, 208,1)" },
]),
new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: "rgba(255, 234, 90, 0)" },
{ offset: 0.5, color: "rgba(255, 234, 90, 0.5)" },
{ offset: 1, color: "rgba(255, 234, 90, 1)" },
]),
];
return colorList[params.dataIndex % colorList.length];
color: "rgba(180, 180, 180, 0.2)", //
},
data: data.map(() => max),
barWidth: 40, //
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)",
},
],
},
},
},
label: {
show: true,
width: 8,
height: 8,
borderRadius: 1000,
color: "rgba(0,0,0,0)",
backgroundColor: "rgba(0, 230, 255, 1)",
shadowColor: "#00E6FF",
position: ["99%", -1.5],
shadowBlur: 6,
type: "bar",
},
//
{
name: "",
type: "pictorialBar",
symbol: "circle",
symbolSize: [20, 8],
symbolOffset: [0, -4],
z: 3,
itemStyle: {
normal: {
// color: (params) => params.data.endColor,
color: "rgba(56, 251, 254, 1)",
label: {
show: false, //
position: "top", //
textStyle: {
fontSize: "12",
color: "#B0E1FF",
},
},
},
},
symbolPosition: "end",
data: data,
},
],
// series: [
// //
// {
// name: '',
// type: 'pictorialBar',
// symbolSize: [16, 8], //
// symbolOffset: [0, 4], //
// z: 3,
// symbol: 'diamond',
// itemStyle: {
// color: params => params.data.startColor
// },
// data: this.data
// },
// //
// {
// name: '',
// type: 'bar',
// barWidth: 16, //
// barGap: '-100%', //
// itemStyle: {
// color: (params) => {
// return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
// { offset: 0, color: params.data.startColor },
// { offset: 1, color: params.data.endColor }
// ]);
// },
// },
// data: this.data
// },
// //
// {
// name: '',
// type: 'pictorialBar',
// symbol: 'diamond',
// symbolSize: [16, 8],
// symbolOffset: [0, -4],
// z: 3,
// itemStyle: {
// normal: {
// color: params => params.data.endColor,
// label: {
// show: true, //
// position: 'top', //
// textStyle: {
// fontSize: '12',
// color: '#B0E1FF',
// }
// }
// }
// },
// symbolPosition: 'end',
// data: this.data
// },
// ]
};
onMounted(() => {