当前位置: 首页 > news >正文

el-table 的单元格 + 图表 + 排序

<el-table border :data="tableDataThree" height="370px" style="width: 100%"><el-table-column :key="activeName + '8'" width="50" type="index" label="序号" align="center"></el-table-column><el-table-column :key="activeName + '9'" width="100" prop="cityName" label="市" align="center"></el-table-column><el-table-column :key="activeName + '10'" label="数据" align="center"><el-table-column sortable prop="totalCenterMoney" label="总额(万元)" align="center"><template slot-scope="scope"><FormCharts :tableDataThree="tableDataThree" :list="scope.row" type="totalCenterMoney" :value="scope.row.totalCenterMoney" /></template></el-table-column></el-table-column>
</el-table>

表格中的图标 echarts 

<template><div class="echart-box" ref="echartBoxRef"></div>
</template>
<script setup>
import { onMounted, ref } from "vue";
import * as echarts from "echarts";
import "echarts-liquidfill";export default {props: ["tableDataThree","value","type","color"],data() {return {echartBoxRef: "",dataList: [],dataNumber: [],myChart: "",maxTotalCenterMoney:0};},mounted() {this.init();},watch:{value: {handler(newval, oldval) {this.$nextTick(() => {this.init()})},immediate:true,deep:true}},methods: {init() {let typpe = this.typethis.tableDataThree.forEach((e,i) => {  // 初始化最大值为数组中的第一个元素(或更小的值以避免未定义错误)  this.maxTotalCenterMoney = this.tableDataThree[0] ? this.tableDataThree[0].typpe : 0;  // 遍历数组以找到每个字段的最大值  this.tableDataThree.forEach(item => {  if (item.typpe > this.maxTotalCenterMoney) {  this.maxTotalCenterMoney = item.typpe;  }  }); })this.myChart = echarts.init(this.$refs.echartBoxRef); // 图标初始化if(this.color == '1'){this.myChart.setOption({  xAxis: {type: "value",show: false,max: this.maxTotalCenterMoney},yAxis: {type: "category",show: false},series: [{data: [this.value],type: "bar",barWidth: "10%",showBackground: true,backgroundStyle: {color: '#dce0ee',borderRadius:5},label: {show: true,position: [0, -10],   //value的位置color: '#000', //值的颜色fontSize: 10,},itemStyle: {color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 1, color: "#6d9cd5" },{ offset: 0, color: "#a8c9e6" }]),barBorderRadius: [2, 2, 2, 2],}}]});  window.addEventListener('resize', () => {  this.myChart.resize();  }); }else{this.myChart.setOption({  xAxis: {type: "value",show: false,max: this.maxTotalCenterMoney},yAxis: {type: "category",show: false},series: [{data: [this.value],type: "bar",barWidth: "10%",showBackground: true,backgroundStyle: {color: '#dee2ef',borderRadius:5},label: {normal: {show: true,position: [0, -10],   //value的位置color: '#000', //值的颜色fontSize: 10,}},itemStyle: {color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [{ offset: 1, color: "#8894c4" },{ offset: 0, color: "#bfc6e4" }]),barBorderRadius: [2, 2, 2, 2],}}]});  window.addEventListener('resize', () => {  this.myChart.resize();  });  }},}
};
</script>
<style lang="scss" scoped>
.echart-box {width: 180px;height: 50px;margin-top: 10px;margin-bottom: -15px;
}
</style>

参考文档:

实现el-table中嵌套echarts图表以及柱条渐变_el-table-v2+echarts-CSDN博客

http://www.lryc.cn/news/437339.html

相关文章:

  • FPGA第 9 篇,Verilog 中的关键字和基数
  • 什么是单元测试?怎么做?
  • 论文复现--基于LeNet网络结构的数字识别
  • Vue3 响应式工具函数isRef()、unref()、isReactive()、isReadonly()、isProxy()
  • 数据结构之简单选择排序介绍与举例
  • 九、Redis 的实际使用与Redis的设计
  • 乔拓云模板助力,微信小程序快速上线无需愁备案
  • Android命令行查看CPU频率和温度
  • 力扣: 翻转字符串里的单词
  • Wophp靶场寻找漏洞练习
  • 国内智能运维厂商月度动态 202408
  • C++ 左值与右值浅谈
  • oracle 如何查死锁
  • 如何编写ChatGPT提示词
  • java项目之基于Spring Boot智能无人仓库管理源码(springboot+vue)
  • 大厂前端常见的笔试题目
  • 网络插件 Cilium 更换 Calico
  • SpringSecurity原理解析(二):认证流程
  • 数据中台 | 数据资源管理平台介绍
  • 智慧环保平台建设方案
  • SpringMVC映射请求;SpringMVC返回值类型;SpringMVC参数绑定;
  • 【第28章】Spring Cloud之Sentinel注解支持
  • 鼎捷新一代PLM 荣膺维科杯 “2023年度行业优秀产品奖”
  • 如何升级用 Helm 安装的极狐GitLab Runner?
  • 08 vue3之认识bem架构及less sass 和scoped
  • 静态库的制作
  • PHP在现代Web开发中的高效应用与最佳实践
  • 大数据-134 - ClickHouse 集群三节点 安装配置启动
  • 2024网络安全人才实战能力白皮书安全测试评估篇
  • [项目][WebServer][解析错误处理]详细讲解