Newer
Older
Nanping_sponge_GCGL / src / views / homeEcharts / queryChat.vue
@liyingjing liyingjing on 25 Oct 2 KB 海绵工程管理
<template>
  <div ref="assetEchart" class="asset_echart"></div>
</template>
<script setup>
import { init } from 'echarts';
import { reactive, ref, onMounted } from 'vue';
const assetEchart = ref(null);
let { data:{xData,legend,yData:{contractCount,paymentMoney,contractMoney}} } = defineProps(['data'])
let options = reactive( {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      crossStyle: {
        color: '#999'
      }
    }
  },
  legend: {
    data: legend
  },
  grid:{
    left:"1%",
    right:"0%",
    bottom:"12%",
    containLabel:true,
  },
  xAxis: [
    {
      type: 'category',
      data: xData,
      axisPointer: {
        type: 'shadow'
      }
    }
  ],
  yAxis: [
    {
      type: 'value',
      name: '数量',
      min: 0,
      interval:10,
      axisLabel: {
        formatter: '{value}'
      }
    },
    {
      type: 'value',
      name: legend[2],
      interval: 5,
      axisLabel: {
        formatter: '{value}'
      }
    }
  ],
  series: [
    {
      barWidth:'18px',
      name: legend[0],
      type: 'bar',
      tooltip: {
        valueFormatter: function (value) {
          return value ;
        }
      },
      data: paymentMoney,
      itemStyle: {
            color: '#0f69ff'
        }
    },
    {
      name:  legend[1],
      type: 'line',
      yAxisIndex: 1,
      tooltip: {
        valueFormatter: function (value) {
          return value;
        }
      },
      data: contractMoney,

      smooth:true,
      itemStyle: {
        normal: {
          color:'#ffa773', //折线点的颜色
          borderColor: '#fff', //拐点边框颜色
          borderWidth: 5, //拐点边框大小
        },
      },
      lineStyle: {
        color:'#ffa773', //折线的颜色
      },
    }
  ]
})
onMounted(() => {
  const chart = init(assetEchart.value);
  chart.setOption(options);
  window.addEventListener('resize', () => {
    chart.resize()
  })
})
</script>

<style lang="scss" scoped>
.asset_echart {
  width: 530px;
  height: 100%;
  margin: 10px 14px 0 16px;
  padding: 24px;
  &_echart {
    width: 100%;
    height: 100%;
  }
}
</style>