|
|
@ -62,7 +62,22 @@ export default { |
|
|
|
direction: data.direction |
|
|
|
} |
|
|
|
}).then(resLastYear=>{ |
|
|
|
chartsStatistics.xAxis.data = res.data.map(x=>x.name); |
|
|
|
//将字符串按照 '-' 分割成两行 |
|
|
|
function splitNameByDash(name) { |
|
|
|
const parts = name.split('-'); |
|
|
|
if (parts.length > 1) { |
|
|
|
return `${parts[0]}\n${parts.slice(1).join('-')}`; |
|
|
|
} |
|
|
|
return name; |
|
|
|
} |
|
|
|
chartsStatistics.xAxis.data = res.data.map(x=>splitNameByDash(x.name)); |
|
|
|
chartsStatistics.xAxis.axisLabel = { |
|
|
|
fontSize: 15, // 调整字体大小 |
|
|
|
formatter: function (value) { |
|
|
|
return value; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
chartsStatistics.series[0].data = res.data.map(x=>x.totalPassengerFlow); |
|
|
|
chartsStatistics.series[1].data = res.data.map(x=>x.typeTruckFlow); |
|
|
|
chartsStatistics.series[2].data = res.data.map(x=>x.typeSpecialVehicleFlow); |
|
|
@ -78,6 +93,8 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
// 将字符串按照 '-' 分割成两行 |
|
|
|
|
|
|
|
// this.$nextTick(() => { |
|
|
|
// var myChart = echarts.init(document.getElementById("anaFlow")); |
|
|
|
// myChart.setOption(chartsStatistics); |
|
|
|