调柱状图

在这里插入图片描述

<template>
  <chart style="width:100%; height:100px;"
         :options="orgOptions"
         :auto-resize="true"></chart>
</template>

<script>
import echarts from 'echarts'
export default {

  name: 'barChartGDYJ',
  data () {
    return {
      orgOptions: {}
    }
  },
  methods: {
    getInfoSucc () {
      this.orgOptions = {
        legend: { // 图例说明
          itemWidth: 18,
          itemHeight: 10, // 小图标高度
          textStyle: {
            color: '#85a6db'
          }
        },
        tooltip: {},
        grid: {
          left: '0%',
          right: '5%',
          top: '30%',
          bottom: '10%',
          containLabel: true
        },
        dataset: {
          source: [
            ['product', '红色预警', '黄色预警', '蓝色预警'],
            ['食品安全(11)', 5, 1, 5],
            ['消防安全(6)', 2, 3, 1],
            ['综合治理(6)', 4, 1, 1]
          ]
        },
        xAxis: { // x轴
          type: 'category',
          axisLine: { // 设置坐标轴和坐标轴字体颜色
            lineStyle: {
              color: '#85a6db',
              width: 0
            }
          }
        },
        yAxis: { // y轴
          min: 0, // 刻度最小值
          max: 6, // 刻度最大值
          splitNumber: 2, // 刻度间隔
          interval: 3, // 横线数
          axisLine: { // 坐标抽
            lineStyle: { // 设置坐标轴和坐标轴字体颜色
              color: '#5767a0',
              width: 0
            }
          },
          splitLine: { // 网格线
            show: true,
            lineStyle: {
              color: '#5767a0',
              width: 1
            }
          }

        },
        series: [
          {
            type: 'bar',
            barWidth: 12, // bar的宽度
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient( // bar设置渐变色
                  0, 0, 0, 1,
                  [
                    { offset: 0, color: '#8b1909' },
                    { offset: 1, color: '#691004' }
                  ]
                )

              }
            }
          },
          {
            type: 'bar',
            barWidth: 12, // bar的宽度
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient( // bar设置渐变色
                  0, 0, 0, 1,
                  [
                    { offset: 0, color: '#c1571a' },
                    { offset: 1, color: '#a44813' }
                  ]
                )

              }
            }
          },
          {
            type: 'bar',
            barWidth: 12, // bar的宽度
            itemStyle: {
              normal: {
                color: new echarts.graphic.LinearGradient( // bar设置渐变色
                  0, 0, 0, 1,
                  [
                    { offset: 0, color: '#195cad' },
                    { offset: 1, color: '#09356b' }
                  ]
                )

              }
            }
          }
        ]

      }
    }
  },

  mounted () {
    this.getInfoSucc()
  }
}
</script>

<style scoped>
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值