import useUserStore from '@/store/modules/user'; import * as echarts from 'echarts'; const pinias = useUserStore(); let optionChart = { // 柱状图+折线图 option: { color: pinias.$state.chartColor, // 显示暂无数据 graphic: { type: 'text', // 类型:文本 left: 'center', top: 'middle', silent: true, // 不响应事件 invisible: false, // 有数据就隐藏 style: { fill: '#c6c6c6', fontWeight: 'bold', text: '暂无数据', fontFamily: 'Microsoft YaHei', fontSize: '18px', }, }, tooltip: { trigger: 'axis', confine: true, //是否将 tooltip 框限制在图表的区域内 }, title: { left: 'left', text: '', top: 10, bottom: 10, left: 10, textStyle: { color: '#545E75', //字体颜色 fontSize: 16, //字体大小 }, }, grid: { left: '3%', right: '5%', top: '20%', bottom: '3%', containLabel: true, }, legend: { top: '2%', orient: 'horizontal', //horizontal left: 'center', //left ,center textStyle: { color: 'inherit', }, }, xAxis: { type: 'category', position: 'bottom', data: ['2023', '2024', '2025'], axisLabel: { color: '#c6c6c6', }, axisLine: { lineStyle: { color: '#066592', }, }, }, yAxis: [ { name: '降雨量(mm)', type: 'value', inverse: true, //翻转 nameLocation: 'start', // 坐标轴名称显示位置 nameGap: 15, // 坐标轴名称与轴线之间的距离 nameTextStyle: { color: '#c6c6c6', //字体颜色 fontSize: 12, //字体大小 align: 'center', // 文字水平对齐方式,默认自动('left','center','right') }, splitLine: { lineStyle: { type: 'dashed', color: '#066592', }, }, axisLabel: { color: '#c6c6c6', }, }, { name: '流量(m³/h)', type: 'value', nameLocation: 'end', // 坐标轴名称显示位置 nameGap: 15, // 坐标轴名称与轴线之间的距离 nameTextStyle: { color: '#c6c6c6', //字体颜色 fontSize: 12, //字体大小 align: 'center', // 文字水平对齐方式,默认自动('left','center','right') }, axisLabel: { color: '#c6c6c6', }, splitLine: { lineStyle: { type: 'dashed', color: '#066592', }, }, }, ], series: [ { name: '降雨量', type: 'bar', barWidth: 10, yAxisIndex: 0, data: [24, 12, 9], }, { name: '进口流量', type: 'line', smooth: true, yAxisIndex: 1, symbolSize: 8, data: [14, 8, 5], }, { name: '出口流量', type: 'line', smooth: true, yAxisIndex: 1, symbolSize: 8, data: [4, 2, 1], }, ], }, }; export default optionChart;