Echarts极坐标系下的堆叠柱状图

Echarts极坐标系下的堆叠柱状图

在这里插入图片描述

<template>
  <div>
    <p class="trave_title">{{ title }}</p>
    <div :style="'width: 100%;' + 'height:' + height + ';'" :id="id"></div>
  </div>
</template>
<script>
import * as echarts from "echarts";

export default {
  name: "qiantaobt2",
  props: {
    id: String,
    title: String,
    colorArr: Object,
    height: String,
    polarBarData: Array,
  },
  data() {
    return {};
  },
  mounted() {
    this.initEchart(this.id);
  },
  methods: {
    initEchart(id) {
      var chartDom = document.getElementById(id);
      chartDom.removeAttribute("_echarts_instance_");

      var myChart = echarts.init(chartDom);

      var option;

      option = {
        angleAxis: {
          //极坐标系的角度轴
          type: "value",
          axisLine: {
            //坐标轴轴线设置
            lineStyle: {
              color: "#fff",
            },
          },
          axisLabel: {
            //刻度标签设置
            textStyle: {
              color: "#fff",
            },
            formatter: "{value} %",
          },
        },
        radiusAxis: {
          type: "category",
          data: this.polarBarData,
          z: 10,
          axisLabel: {
            interval: 0,
            //刻度标签设置
            textStyle: {
              color: "#fff",
            },
          },
        },

        polar: {
          center: ["50%", "55%"],
          radius: ["00%", "70%"],
        },
        tooltip: {},
        series: [
          {
            type: "bar",
            data: [10, 20, 30, 10],
            coordinateSystem: "polar",
            name: "时间不敏感-价格敏感",
            stack: "a",
          },
          {
            type: "bar",
            data: [20, 30, 20, 10],
            coordinateSystem: "polar",
            name: "时间敏感-价格不敏感",
            stack: "a",
          },
          {
            type: "bar",
            data: [30, 30, 10, 30],
            coordinateSystem: "polar",
            name: "时间价格均敏感",
            stack: "a",
          },
          {
            type: "bar",
            data: [40, 20, 40, 50],
            coordinateSystem: "polar",
            name: "时间价格均不敏感",
            stack: "a",
          },
        ],
        legend: {
          show: true,
          data: [
            "时间不敏感-价格敏感",
            "时间敏感-价格不敏感",
            "时间价格均敏感",
            "时间价格均不敏感",
          ],
          textStyle: {
            color: "#fff",
          },
        },
      };

      option && myChart.setOption(option);
    },
  },
};
</script>
<style lang="scss">
</style>

polarBarData数据

polarBarData: ["商务座", "二等座", "硬座硬卧"],
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值