| | |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div> |
| | | <div class="select-container"> |
| | | <el-select v-model="params.category" placeholder="数据类型" @change="getChart" clearable> |
| | | <el-option v-for="item in categories" :key="item.label" :label="item.label" :value="item.value"> |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <div class="select-container"> |
| | | <el-date-picker v-model="date" format="yyyy-MM" value-format="yyyy-MM" type="month" placeholder="选择月份" |
| | | @change="dateChange"> |
| | | </el-date-picker> |
| | |
| | | date: '', |
| | | params: { |
| | | month: '', |
| | | category: 1 |
| | | }, |
| | | categories: [ |
| | | {label: '累计数据', value: 1}, |
| | | {label: '每日数据', value: 2}, |
| | | ], |
| | | options: [ |
| | | {label: '省厅', value: 1} |
| | | ], |
| | |
| | | return tempArray; |
| | | }, |
| | | getAllDay() { |
| | | const currentDate = this.date.split('-'); |
| | | const currentYear = currentDate[0]; |
| | | const currentMonth = currentDate[1]; |
| | | // 获取当前日期 |
| | | const currentDate = new Date(); |
| | | const currentYear = currentDate.getFullYear(); |
| | | const currentMonth = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,需要加1并补零 |
| | | // 获取当前月份的天数 |
| | | const daysInMonth = new Date(currentYear, currentMonth, 0).getDate(); |
| | | // 存储当前月份每一天的日期 |
| | | const datesOfMonth = []; |
| | | for (var day = 1; day <= daysInMonth; day++) { |
| | | const formattedDate = currentMonth + '-' + (day.toString().padStart(2, '0')); |
| | |
| | | if (!data.list || data.list.length === 0) { |
| | | snapCount = 0; |
| | | }else { |
| | | snapCount = data.list[data.list.length - 1].snapCount |
| | | snapCount = data.list.reduce((max, item) => Math.max(max, item.snapCount), 0) |
| | | } |
| | | const yMax = Math.max(snapCount, baseLine * 1.2); |
| | | const yMax = Math.max(snapCount * 1.2, baseLine * 1.2); |
| | | let interval = 1; |
| | | while ((yMax) / interval > 100) { // 这里的 100 是一个阈值,您可以根据需要调整 |
| | | interval *= 10; |
| | | } |
| | | const colors = ['#5470C6', '#66CC99', '#EE6666']; |
| | | option = { |
| | | color: colors, |
| | |
| | | axisLabel: { |
| | | formatter: function (value) { |
| | | // 返回整数部分,或使用其他逻辑来格式化标签 |
| | | return Math.floor(value); |
| | | return Math.floor(value / interval) * interval; |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | .select-container { |
| | | margin: 0 20px; |
| | | margin-left: 20px; |
| | | width: 180px; |
| | | } |
| | | </style> |