echarts

// An highlighted block
<template>
    <div :class="className" :style="{ height: height, width: width }" />
  </template>
  
  <script>
  let colorList = [
  "#1890ff",
  "#52c41a",
  "#faad14",
  "#f5222d",
  "#1DA57A",
  "#d9d9d9",
];
  export default {
  
    props: {
      className: {
        type: String,
        default: 'chart02'
      },
      width: {
        type: String,
        default: '100%'
      },
      height: {
        type: String,
        default: '200px'
      },
      chartData: {
        type: Object
      }
    },
    data() {
      return {
        chart: null,
        timechartes: null,
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.initChart()
      })
    },
    beforeDestroy() {
      if (!this.chart) {
        return
      }
      this.chart.dispose()
      this.chart = null
    },
    methods: {
      initChart() {
        let that = this
        that.chart = this.$echarts.init(this.$el, 'macarons')
        let option = {
          title:{
            text: '标题文字',
            textStyle:{
                  color:"#fff",
                  fontSize:14
              }
            },
          tooltip: { // 鼠标悬浮提示框显示 X和Y 轴数据
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            },
  
            backgroundColor: 'rgba(32, 33, 36,0.7)',
            textStyle: {
              color: '#fff',
            },
          },
          // dataZoom: [
          //   {
          //     show: true,
          //     height: 6,
          //     type: 'slider', 
          //     xAxisIndex: 0,
          //     left: 30, 
          //     right: 30,
          //     bottom: 10,
          //     showDetail: false,
          //     fillerColor: '#2060a0'
          //   },
          //   {
          //     type: 'inside',
          //     show: true,
          //     height: 6,
          //     start: 1,
          //     end: 5
          //   }
          // ],
          grid: {
            top: '40',
            left: '3%',
            right: '10%',
            bottom: '0',
            containLabel: true
          },
          xAxis: {
            type: "value",
            axisLabel: {
              show:false
            },
            splitLine: {
              "show": false
            }
          },
          yAxis: {
            type: "category",
            data: that.chartData.xData,
            // 轴刻度
            axisTick: {
              show: false
            },
            //轴线
            axisLine:{
              show:false
            },
            //轴文字
            axisLabel: {
                color: '#c0d1f2'
            },
            //网格线
            splitLine: {
                show: false,
                lineStyle: {
                  color: 'rgba(22, 207, 208, 0.2)',
                  width: 0.5,
                  type: 'dashed'
                }
              },
            //背景  
            splitArea: {
                show: false,
            }
        },
          series: [
            {
              data: that.chartData.yData01,
              type: 'bar',
              name: '一xx',
              itemStyle: {
                barBorderRadius: [0, 4, 4, 0],
                color: (params) => {
                  return colorList[params.dataIndex];
                },
              },
              barWidth: 8,
              label: {
                  show: true,
                  fontSize: 12,
                  textStyle: {
                    color: '#fff',
                  },
                  position: 'right',
                  // formatter: (param) => {
                  //   let result = ''
                  //   result = `${param.data}%`
                  //   return result
                  // }
                }
            }
          ]
        }
        that.chart.setOption(option)
      }
    }
  }
  </script>
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值