vue elementui el-table 表格里边展示四分位图

embedded/2024/9/23 5:55:57/

elementui_eltable__0">vue elementui el-table 表格里边展示四分位图

直接上代码(效果图在文章末尾):

父组件:

<template>
<el-table size="small":header-cell-style="headerCellStyle()"style="width: 100%;"highlight-current-rowrow-key="index":data="tableData1" ><el-table-columnlabel="标题1"prop="name1"align="left"><template slot-scope="scope"><span>{{ scope.row.name1}}</span></template></el-table-column><el-table-columnlabel="数据1"prop="value1"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value1"></quartileChart></div><span v-else>{{ scope.row.value1}}</span></template></el-table-column><el-table-columnlabel="数据2"prop="value2"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value2"></quartileChart></div><span v-else>{{ scope.row.value2}}</span></template></el-table-column><el-table-columnlabel="数据3"prop="value3"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value3"></quartileChart></div><span v-else>{{ scope.row.value3}}</span></template></el-table-column><el-table-columnlabel="数据4"prop="value4"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value4"></quartileChart></div><span v-else>{{ scope.row.value4}}</span></template></el-table-column><el-table-columnlabel="数据5"prop="value5"align="center"><template slot-scope="scope"><div v-if="scope.row.name1 === '指标4'"><quartileChart :quartile="scope.row.value5"></quartileChart></div><span v-else>{{ scope.row.value5}}</span></template></el-table-column></el-table>
</template>
<script>javascript">
import quartileChart from '@/components/quartileChart.vue' // 引入子组件(四分位图),注意引入路径
export default {
components: { quartileChart },data() {return {tableData1: [{name1: '指标1',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标2',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标3',value1: '0.33%', value2: '0.33%', value3: '0.33%', value4: '0.33%', value5: '0.33%', },{name1: '指标4',value1: '1', value2: '2', value3: '3', value4: '4', value5: null, }]}methods: {headerCellStyle () {return {color: " #333 !important", backgroundColor: "#cedff3  !important",fontSize: '14px',fontWeight: 500,}}}}
}</script>

子组件:

<template><div><div v-if="5 - Number(quartile) === 1" class="ranking rank_1"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 2" class="ranking rank_2"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 3" class="ranking rank_3"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else-if="5 - Number(quartile) === 4" class="ranking rank_4"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div><div v-else class="ranking rank_5"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div></div>
</template><script>javascript">
export default {name: 'quartileChart',components: {},props: {quartile: {type: String,}},data () {return {}},created () {},mounted () {},computed: {},watch: {},methods: {},
}
</script><style lang="scss" scoped>
.ranking{width: 47px;margin: 0 auto;height: 39px;margin-top: 1px;margin-bottom: 2px;div {height: 9px;zoom: 1;overflow: hidden;border: 1px solid #dcdcdc;margin-top: -1px;}
}
.rank_1 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_2 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_3 { .r4 {height: 11px;}.r3 {border: 0;background: #b3ceef;height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_4 { .r4 {border: 0;background: #94b7e3;height: 11px;}.r3 {border: 0;background: #b3ceef;height: 11px;}.r2 {border: 0;background: #cbdff8;height: 11px;}.r1 {border: 0;background: #e1edfc;height: 11px;}
}
.rank_5 { .r4 {height: 11px;}.r3 {height: 11px;}.r2 {height: 11px;}.r1 {height: 11px;}
}</style>

展示效果图:

在这里插入图片描述


http://www.ppmy.cn/embedded/19540.html

相关文章

OpenHarmony实战开发-使用SmartPerf-Host分析应用性能

简介 SmartPerf-Host是一款深入挖掘数据、细粒度展示数据的性能功耗调优工具&#xff0c;可采集CPU调度、频点、进程线程时间片、堆内存、帧率等数据&#xff0c;采集的数据通过泳道图清晰地呈现给开发者&#xff0c;同时通过GUI以可视化的方式进行分析。该工具当前为开发者提…

Docker基本操作 容器相关命令

docker run:运行镜像; docker pause:暂停容器&#xff0c;会让该容器暂时挂起&#xff1b; docker unpauser:从暂停到运行; docker stop:停止容器&#xff0c;杀死进程; docker start:重新创建进程。 docker ps&#xff1a;查看所有运行的容器及其状态&#xff0c;默认只展…

【网站项目】考研助手

&#x1f64a;作者简介&#xff1a;拥有多年开发工作经验&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的项目或者毕业设计。 代码可以私聊博主获取。&#x1f339;赠送计算机毕业设计600个选题excel文件&#xff0c;帮助大学选题。赠送开题报告模板&#xff…

力扣HOT100 - 543. 二叉树的直径

解题思路&#xff1a; class Solution {int ans;//记录节点数public int diameterOfBinaryTree(TreeNode root) {ans 1;depth(root);return ans - 1;//节点数减 1 就是路径长度}public int depth(TreeNode root) {if (root null) return 0;int l depth(root.left);int r de…

与 Apollo 共创生态:揭秘Apollo开放平台企业生态计划

自2013年百度开始布局自动驾驶&#xff0c;2017年推出全球首个自动驾驶开发平台Apollo。目前百度Apollo已经在自动驾驶、智能汽车等领域拥有业内领先的解决方案。截止2023年12月&#xff0c;自动驾驶出行服务平台萝卜快跑累计订单量500万。计划至2023年底将萝卜快跑自动驾驶出行…

React真的好难用

我发现React就像个宗教一样&#xff0c;网络上总有一群信徒。信徒&#xff1a;React天下第一&#xff0c;谁也不能说他不好。 网络上大佬对React的评价一般有几类&#xff1a; React跟Vue比就是手动档和自动档的区别&#xff0c;高手都开手动档。—— 就一个破打工的&#xf…

状态模式:管理状态转换的策略

在软件设计中&#xff0c;某些对象在其生命周期内会有不同的状态&#xff0c;并且这些状态之间可以相互转换。状态模式&#xff08;State Pattern&#xff09;是一种行为型设计模式&#xff0c;它允许一个对象在其内部状态改变时改变其行为。这个模式将各种状态转移逻辑封装在独…

【前端】5. JavaScript(基础语法)

JavaScript 是什么 JavaScript (简称 JS) 是世界上最流行的编程语言之一是一个脚本语言, 通过解释器运行主要在客户端(浏览器)上运行, 现在也可以基于 node.js 在服务器端运行. JavaScript 最初只是为了完成简单的表单验证(验证数据合法性), 结果后来不小心就火了. 当前 Jav…