| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <template>
- <!-- <div class="dashboard-line-box"> -->
- <div class="dashboard-line-box">
- <div class="dashboard-line-title">
- 近一年工单数
- </div>
- <div
- ref="echart"
- class="dashboard-line"
- />
- </div>
- </template>
- <script setup>
- import * as echarts from 'echarts'
- import { nextTick, onMounted, onUnmounted, ref, shallowRef } from 'vue'
- // import 'echarts/theme/macarons'
- // import {
- // index
- // } from '@/api/jixiaoguanli/jitairibaobiao'
- var dataAxis = [
-
- ]
- // for (var i = 1; i < 13; i++) {
- // dataAxis.push(`${i}月`)
- // }
- const getindex = async () => {
- //接口调用函数
- const response = await index();
- console.log()
- response.data.monthData.forEach(item => {
- dataAxis.push(item.month);
- data.push(item.count)
- });
- console.log(dataAxis);
- console.log(data);
- // 数据填充后更新图表数据
- if (chart.value) {
- setOptions();
- }
- }
- getindex()
- var data = [
- ]
- var yMax = 500
- var dataShadow = []
- // eslint-disable-next-line no-redeclare
- for (var i = 0; i < data.length; i++) {
- dataShadow.push(yMax)
- }
- const chart = shallowRef(null)
- const echart = ref(null)
- const initChart = () => {
- chart.value = echarts.init(echart.value /* 'macarons' */)
- setOptions()
- }
- const setOptions = () => {
- chart.value.setOption({
- grid: {
- left: '40',
- right: '20',
- top: '40',
- bottom: '20',
- },
- xAxis: {
- data: dataAxis,
- axisTick: {
- show: false,
- },
- axisLine: {
- show: false,
- },
- z: 10,
- },
- yAxis: {
- axisLine: {
- show: false,
- },
- axisTick: {
- show: false,
- },
- axisLabel: {
- textStyle: {
- color: '#999',
- },
- },
- },
- dataZoom: [
- {
- type: 'inside',
- },
- ],
- series: [
- {
- type: 'bar',
- barWidth: '40%',
- itemStyle: {
- borderRadius: [5, 5, 0, 0],
- color: '#188df0',
- },
- emphasis: {
- itemStyle: {
- color: '#188df0',
- },
- },
- data: data,
- },
- ],
- })
- }
- onMounted(async() => {
- await nextTick()
- initChart()
- })
- onUnmounted(() => {
- if (!chart.value) {
- return
- }
- chart.value.dispose()
- chart.value = null
- })
- </script>
- <style lang="scss" scoped>
- .dashboard-line-box {
- .dashboard-line {
- background-color: #fff;
- height: 360px;
- width: 80%;
- }
- .dashboard-line-title {
- font-weight: 600;
- margin-bottom: 12px;
- }
- }
- </style>
|