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({ const data = reactive({
list: [], list: [709, 3424, 2064, 2980, ,],
list2: [], unlist: [, , , 2980, 1790, 3100],
list3: [], list2: [1548, 5895, 2753, 4602, ,],
unlist2: [, , , 4602, 2030, 3900],
list3: [180, 930, 632, 780, ,],
unlist3: [, , , 780, 520, 600],
year: [], year: [],
option: {}, option: {},
bg: [], bg: [],
@ -44,10 +47,11 @@ const data = reactive({
const chart = ref(); // DOM const chart = ref(); // DOM
const getOption = () => { const getOption = () => {
data.option = { data.option = {
tooltip: { // tooltip: {
trigger: "axis", // trigger: "axis",
padding: [20, 10, 20, 10], // padding: [20, 10, 20, 10],
}, // formatter: "{b0}:</br>{a0}:{c0}</br>{a1}:{c1}</br>{a2}:{c2}",
// },
legend: { legend: {
data: ["0-18岁", "19-60岁", "60岁以上"], data: ["0-18岁", "19-60岁", "60岁以上"],
top: "3%", top: "3%",
@ -104,7 +108,7 @@ const getOption = () => {
}, },
series: [ series: [
{ {
xAxisIndex: 0, xAxisIndex: 0,
name: "0-18岁", name: "0-18岁",
type: "line", type: "line",
// stack: "Total", // stack: "Total",
@ -154,7 +158,7 @@ const getOption = () => {
data: data.list, data: data.list,
}, },
{ {
xAxisIndex: 0, xAxisIndex: 0,
name: "19-60岁", name: "19-60岁",
type: "line", type: "line",
// stack: "Total", // stack: "Total",
@ -170,7 +174,7 @@ const getOption = () => {
show: true, show: true,
color: "#ffffff", color: "#ffffff",
position: "top", position: "top",
fontSize: 16, fontSize: 16,
formatter: function (data) { formatter: function (data) {
return data.value; return data.value;
}, },
@ -203,7 +207,7 @@ const getOption = () => {
data: data.list2, data: data.list2,
}, },
{ {
xAxisIndex: 0, xAxisIndex: 0,
name: "60岁以上", name: "60岁以上",
type: "line", type: "line",
// stack: "Total", // stack: "Total",
@ -219,7 +223,7 @@ const getOption = () => {
show: true, show: true,
color: "#ffffff", color: "#ffffff",
position: "top", position: "top",
fontSize: 16, fontSize: 16,
formatter: function (data) { formatter: function (data) {
return data.value; return data.value;
}, },
@ -250,6 +254,161 @@ const getOption = () => {
}, },
data: data.list3, 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, () => props.list,
(newValue, oldValue) => { (newValue, oldValue) => {
setTimeout(() => { setTimeout(() => {
data.list = props.list; // data.list = props.list;
data.list2 = props.list2; // data.list2 = props.list2;
// data.list3 = props.list3;
data.year = props.year; data.year = props.year;
getOption(); getOption();
setChart(); setChart();
@ -276,9 +436,9 @@ const setChart = () => {
onBeforeMount(() => { onBeforeMount(() => {
setTimeout(() => { setTimeout(() => {
data.list = props.list; // data.list = props.list;
data.list2 = props.list2; // data.list2 = props.list2;
data.list3 = props.list3; // data.list3 = props.list3;
data.year = props.year; data.year = props.year;
getOption(); getOption();
setChart(); setChart();