treemapChart.vue 1.79 KB
<template>
  <div>
    <basic ref="basic" :chartId="chartId" :chartData="chartData"></basic>
  </div>
</template>
<script>
import mixin from "./mixin";
export default {
  mixins: [mixin],
  data() {
    return {};
  },
  methods: {
    /**
     * 预处理option参数
     * */
    preChartData(cdata) {
      return cdata;
    },
    /**
     * 处理option参数
     * */
    dealChartData(optionFormat) {
      // 特殊配置项
      let { _color, yAxisName, doubleYaxis, isSwapY, grid } =
        optionFormat.otherConf;
      optionFormat.xAxis.show = false;
      optionFormat.yAxis.show = false;
      optionFormat.legend.show = false;
      optionFormat.color = _color;
      optionFormat.series.forEach((item, index) => {
        item.width = "100%";
        item.height = "100%";
        item.roam = true;
        item.itemStyle = {
          gapWidth: 1,
          color: "#f00",
        };
        item.label = {
          position: "inside",
          formatter: function (params) {
            let html = `${params.name}\n${params.value}${painter.$t('format.perTime')}\n${(
              (params.value / params.treePathInfo[1].value) *
              100
            ).toFixed(2)}%`;
            return html;
          },
        };
        item.breadcrumb = {
          itemStyle: {
            //color:'#f00'
          },
        };
      });
      let option = Object.assign({}, optionFormat);
      option.tooltip.formatter = (params) => {
        let htmls = "";
        htmls += `<span>业态: ${
          params.data.path.split("/")[0]
        }</span><br/><span>店铺: ${params.name}</span><br/><span>客流: ${
          params.value
        }${painter.$t('format.perTime')}</span>`;
        return htmls;
      };
      return option;
    },
  },
  created() {},
};
</script>
<style scoped>
</style>