效果实现:
在yAxis设置中:
yAxis: [
{
type: "value",
splitLine:false,
position: 'left',//控制Y轴的方向
alignTicks: true,
// 改变Y轴颜色
axisLine:{
lineStyle:{
color:'#20E3F1',
}
},
// 改变Y轴字体颜色和大小
axisLabel: {
textStyle: {
color: 'rgba(206, 223, 255, 0.6)',
fontSize:'9'
},
formatter: '{value}'
},
},
{
type: "value",
splitLine:false,
position: 'right',
alignTicks: true,
// 改变Y轴颜色
axisLine:{
lineStyle:{
color:'#20E3F1',
}
},
// 改变Y轴字体颜色和大小
axisLabel: {
textStyle: {
color: 'rgba(206, 223, 255, 0.6)',
fontSize:'9'
},
formatter: '{value}'
},
},
],
在series里面增加yAxisIndex: 1,
series: [
{
name: "用餐人数",
type: "line",
itemStyle: {
color: '#FBC900'
},
areaStyle: {
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(251, 201, 0, 0.3)'
},
{
offset: 1,
color: 'rgba(251, 201, 0, 0.2)'
}
])
},
emphasis: {
focus: "series",
},
data: yPeopleData,
},
{
name: "交易额",
type: "line",
itemStyle: {
color: '#07A9E8'
},
yAxisIndex: 1,//使用的事配置的第二天Y轴
areaStyle: {
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(7, 169, 232, 0.3)'
},
{
offset: 1,
color: 'rgba(7, 169, 232, 0.2)'
}
])
},
emphasis: {
focus: "series",
},
data: yMoneyData,
}
],