【无标题】

简介: 【无标题】

60bd5ef4e03e40d5846d5216cc9b63b1.png

dataZoom: [

          {
            type: 'slider',

              // start: 1,      // 左边在 10% 的位置。

              // end: 100 ,

              width: '100%',

              height: '10',

              right: '0%',

              left: '0%',

              bottom: '0px',

              backgroundColor: '#ddd',//滚到颜色

              // fillerColor: '#1890ff',//滑块颜色

              handeSize: 0,//手柄

              realtime: true,//实时更新

              //filter过滤掉窗口外的数据,none不过滤数据,只改变数轴范围

              filterMode: 'filter',

              //展示10个柱子

              startValue:0, //从0个柱子开始,也就是最起始的地方

              endValue:5, //到第6个柱子结束

              // xAxisIndex:[0],

              show: true

          }

        ],
 
<template>
  <div class="box" ref="colcharts"></div>
</template>
 
<script>
import * as echarts from "echarts";
 
export default {
  props: ['rowCode','tableData'],
  data() {
    return {
      allData:[]
    };
  },
  created() {},
  mounted() {
    this.$nextTick(()=> {
      this.deepData(this.allData,[this.tableData])
      // console.log(this.allData.map(item =>item.fname))
      this.getcharts();
    })
  },
  methods: {
    deepData(arr,rowdata){
      rowdata.map(item=> {
        arr.push(item)
        if(item.children){
         return this.deepData(arr,item.children)
        }     
      })
    },
    async getcharts() {
      let myChart = echarts.init(this.$refs.colcharts);
      let dedicatedData = [45, 80, 16, 52, 74, 50, 56, 88, 92, 16, 52, 74, 50, 56];
      let generalData = [42, 16, 46, 22, 54, 80, 96, 78, 67, 46, 22, 54, 80, 96];
      let labelData = ["长沙市","岳阳市","永州市","张家界市","益阳市","邵阳市","娄底市","湘西州", "常德市", "郴州市", "怀化市", "湘潭市", "衡阳市", "株洲市"];
      if(this.rowCode.ftype == "province"){
        labelData = this.allData.filter(item =>item.ftype=='city').map(item2 => item2.fname)
      }else if(this.rowCode.ftype == "city"){
        labelData = this.allData.filter(item =>item.ftype=='county'&&item.fcode.includes(this.rowCode.fcode)).map(item2 => item2.fname)
      }else{
        labelData = [this.rowCode.fname]
      }
      //对话框图片
      let titleArray = [
        "管护协议签订率",
        "资金发放率",
      ];
      let option = {
        // backgroundColor: "#080c34",
        title: {
          // title为标题部分,有一级标题text,二级标题subtext。这里我们使用二级标题,再修改一下这个二级标题的位置即可出现我们想要的效果了,当然样式也可以通过title.subtextStyle去配置
          subtext: "",
          left: 5, // 距离左边位置
          top: -5, // 距离上面位置
          subtextStyle: {
            // 设置二级标题的样式
            color: "#C9ECFF",
            fontSize:"15px"
          },
        },
        tooltip: {
          show: true,
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
          textStyle: {
            fontSize: 16,
          },
          // 自定义 tooltip
          formatter: function (params) {
            let dom = `${params[0].name}
              <br/>`;
            for (let i of params) {
              dom += `${i.marker}
              ${i.seriesName}
                : 
              ${i.value}%
              <br/>`;
            }
            return dom;
          },
        },
        legend: {
          show: true,
          itemWidth: 10,
          itemHeight: 10,
          x: "center",
          y: "300px",
          data: titleArray,
          textStyle: {
            color: "RGB(193,223,255)",
            fontSize:"14px"
          },
        },
        xAxis: [
          {
            // type: "category",
            // color: "#C9ECFF",
            // data: labelData,
            // axisLabel: {
            //   margin: 20,
            //   color: "#C9ECFF",
            //   textStyle: {
            //     fontSize: 16
            //   }
            // },
            // axisLine: {
            //   lineStyle: {
            //     color: "#C9ECFF"
            //   }
            // },
            type: "category",
            boundaryGap: true,
            data: labelData,
            axisLabel: {
              textStyle: {
                color: "#C9ECFF",
              },
            },
            axisLine: {
              lineStyle: {
                color: "#C9ECFF",
              },
            },
            axisTick: {
              inside: false,
              alignWithLabel: true,
              lineStyle: {
                color: "#fff",
              },
            }
          },
        ],
        dataZoom: [
          {
            type: 'slider',
              // start: 1,      // 左边在 10% 的位置。
              // end: 100 ,
              width: '100%',
              height: '10',
              right: '0%',
              left: '0%',
              bottom: '0px',
              backgroundColor: '#ddd',//滚到颜色
              // fillerColor: '#1890ff',//滑块颜色
              handeSize: 0,//手柄
              realtime: true,//实时更新
              //filter过滤掉窗口外的数据,none不过滤数据,只改变数轴范围
              filterMode: 'filter',
              //展示10个柱子
              startValue:0, //从0个柱子开始,也就是最起始的地方
              endValue:5, //到第6个柱子结束
              // xAxisIndex:[0],
              show: true
          }
        ],
        yAxis: {
          type: "value",
          // name: "单位:万公顷",
          min: 0,
          // max : 100,
          splitNumber: 4,
          axisLabel: {
            textStyle: {
              //   color: "#ffffff"
              color: "#C9ECFF",
            },
          },
          axisLine: {
            show: false,
            lineStyle: {
              color: "#C9ECFF",
            },
          },
          //   分割线
          splitLine: {
            show: true,
            lineStyle: {
              // 使用深浅的间隔色
              color: "#c9ecffbb",
            },
          },
        },
        series: [
          {
            name: titleArray[0],
            type: "bar",
            data: dedicatedData,
            barWidth: "15px",
            itemStyle: {
              normal: {
                color: "#65F1BF",
                barBorderRadius: [0, 0, 0, 0],
              },
            },
          },
          {
            name: titleArray[1],
            type: "bar",
            data: generalData,
            barWidth: "15px",
            itemStyle: {
              normal: {
                color: "#7fa0f9",
                barBorderRadius: [0, 0, 0, 0],
              },
            },
          }
        ],
        grid: {
          bottom:"20%",
        },
      };
      window.addEventListener("resize", () => myChart.resize(), false);
      option && myChart.setOption(option);
    },
  },
  components: {},
};
</script>
 
<style lang="scss" scoped>
.box {
  position: absolute;
  top: 50px;
  bottom: 10px;
  left: 0;
  right: 0;
}
</style>
相关文章
|
Python
如何使用Python的Pandas库进行数据透视图(melt/cast)操作?
Pandas的`melt()`和`pivot()`函数用于数据透视。基本步骤:导入pandas,创建DataFrame,然后使用这两个函数变换数据。示例代码:导入pandas,定义一个包含&#39;Name&#39;和&#39;Age&#39;列的DataFrame,使用`melt()`转为长格式,再用`pivot()`恢复为宽格式。
386 1
|
关系型数据库 MySQL
MySQL中CASE WHEN用法总结
MySQL中CASE WHEN用法总结
1383 0
|
Kubernetes 网络协议 API
k8s查看集群信息及基本命令
集群信息的各种查看基本上是在Master节点操作 1、查看 Node状态 2、查看 Service 信息 3、查看所有名称空间内资源
5783 0
|
JavaScript 前端开发 测试技术
CommonJS、AMD、CMD、ES6 Modules、ES Harmony
CommonJS、AMD、CMD、ES6 Modules、ES Harmony
312 0
CommonJS、AMD、CMD、ES6 Modules、ES Harmony
|
Web App开发 安全 网络安全
Qt之HTTPS登录
简述 HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容需要SSL。它是一个URI scheme(抽象标识符体系),句法类同http:体系。用于安全的HTTP数据传输。
1446 0
|
5天前
|
存储 人工智能 安全
AI 越智能,数据越危险?
阿里云提供AI全栈安全能力,为客户构建全链路数据保护体系,让企业敢用、能用、放心用
|
8天前
|
域名解析 人工智能
【实操攻略】手把手教学,免费领取.CN域名
即日起至2025年12月31日,购买万小智AI建站或云·企业官网,每单可免费领1个.CN域名首年!跟我了解领取攻略吧~
|
7天前
|
数据采集 人工智能 自然语言处理
3分钟采集134篇AI文章!深度解析如何通过云无影AgentBay实现25倍并发 + LlamaIndex智能推荐
结合阿里云无影 AgentBay 云端并发采集与 LlamaIndex 智能分析,3分钟高效抓取134篇 AI Agent 文章,实现 AI 推荐、智能问答与知识沉淀,打造从数据获取到价值提炼的完整闭环。
448 93