This commit is contained in:
duanxiaohai 2024-08-16 17:32:31 +08:00
commit e1c792cba6
1 changed files with 177 additions and 17 deletions

View File

@ -33,9 +33,12 @@ const props = defineProps({
},
});
const data = reactive({
list: [],
list2: [],
list3: [],
list: [709, 3424, 2064, 2980, ,],
unlist: [, , , 2980, 1790, 3100],
list2: [1548, 5895, 2753, 4602, ,],
unlist2: [, , , 4602, 2030, 3900],
list3: [180, 930, 632, 780, ,],
unlist3: [, , , 780, 520, 600],
year: [],
option: {},
bg: [],
@ -44,10 +47,11 @@ const data = reactive({
const chart = ref(); // DOM
const getOption = () => {
data.option = {
tooltip: {
trigger: "axis",
padding: [20, 10, 20, 10],
},
// tooltip: {
// trigger: "axis",
// padding: [20, 10, 20, 10],
// formatter: "{b0}:</br>{a0}:{c0}</br>{a1}:{c1}</br>{a2}:{c2}",
// },
legend: {
data: ["0-18岁", "19-60岁", "60岁以上"],
top: "3%",
@ -250,6 +254,161 @@ const getOption = () => {
},
data: data.list3,
},
{
xAxisIndex: 0,
name: "0-18岁",
type: "line",
// stack: "Total",
symbol: "emptyCircle",
smooth: true,
symbolSize: 10,
lineStyle: {
type: "dashed", // 线'dashed' 'dotted'
},
itemStyle: {
borderColor: "#E8FF00",
borderWidth: 1,
color: "#E8FF00",
},
label: {
show: true,
color: "#ffffff",
position: "top",
fontSize: 16,
formatter: function (data) {
return data.value;
},
},
areaStyle: {
color: "#F4F65B",
normal: {
//线4x0,y0,x2,y2(0~1);true
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
// color: 'RGBA(184, 204, 241, 1)'
color: "rgba(255, 234, 90, 0.50)",
},
{
offset: 1,
color: "rgba(255, 234, 90, 0)",
},
],
false
),
shadowBlur: 0, //shadowBlurshadowColor,shadowOffsetX/Y,
},
},
data: data.unlist,
},
{
xAxisIndex: 0,
name: "19-60岁",
type: "line",
symbol: "emptyCircle",
smooth: true,
symbolSize: 10,
lineStyle: {
type: "dashed", // 线'dashed' 'dotted'
},
itemStyle: {
borderColor: "#00FCFF",
borderWidth: 1,
color: "#00FCFF",
},
label: {
show: true,
color: "#ffffff",
position: "top",
fontSize: 16,
formatter: function (data) {
return data.value;
},
},
areaStyle: {
color: "#F4F65B",
normal: {
//线4x0,y0,x2,y2(0~1);true
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
// color: 'RGBA(184, 204, 241, 1)'
color: "rgba(0, 252, 255, 0.50)",
},
{
offset: 1,
color: "rgba(0, 252, 255, 0)",
},
],
false
),
shadowBlur: 0, //shadowBlurshadowColor,shadowOffsetX/Y,
},
},
data: data.unlist2,
},
{
xAxisIndex: 0,
name: "60岁以上",
type: "line",
// stack: "Total",
symbol: "emptyCircle",
smooth: true,
symbolSize: 10,
lineStyle: {
type: "dashed", // 线'dashed' 'dotted'
},
itemStyle: {
borderColor: "#00A8FF",
borderWidth: 1,
color: "#00A8FF",
},
label: {
show: true,
color: "#ffffff",
position: "top",
fontSize: 16,
formatter: function (data) {
return data.value;
},
},
areaStyle: {
color: "#00A8FF",
normal: {
//线4x0,y0,x2,y2(0~1);true
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: "rgba(0, 168, 255,0.50)",
},
{
offset: 1,
color: "rgba(0, 168, 255,0)",
},
],
false
),
shadowBlur: 0, //shadowBlurshadowColor,shadowOffsetX/Y,
},
},
data: data.unlist3,
},
],
};
};
@ -257,8 +416,9 @@ watch(
() => props.list,
(newValue, oldValue) => {
setTimeout(() => {
data.list = props.list;
data.list2 = props.list2;
// data.list = props.list;
// data.list2 = props.list2;
// data.list3 = props.list3;
data.year = props.year;
getOption();
setChart();
@ -276,9 +436,9 @@ const setChart = () => {
onBeforeMount(() => {
setTimeout(() => {
data.list = props.list;
data.list2 = props.list2;
data.list3 = props.list3;
// data.list = props.list;
// data.list2 = props.list2;
// data.list3 = props.list3;
data.year = props.year;
getOption();
setChart();