<template> <div class="ting-rank"> <ul> <li v-for="(item, index) in list" :key="index + item.text" style="background-image: url('http://42.193.126.16:9000/sjoss/upload/20240618/550a392d60a5e3f6334a526bef1579c3.png')"> <span class="index">{{ index + 1 }}</span> <span class="text">{{ item.text }}</span> <div class="bar-wrapper"> <div class="bar" :style="{ background: colorList[index].barBg, width: (item.value / max)*100 + '%' }"></div> </div> <div class="value-wrapper"> <span :style="{ color: colorList[index].valueColor }">{{ item.value }}</span> <span class="unit">人</span> </div> </li> </ul> </div> </template> <script> export default { name: 'TingRank', data: () => { return { colorList: [ { valueColor: 'rgba(0, 248, 255, 1)', barBg: 'linear-gradient( 270deg, #FFFFFF 0%, #00F8FF 2%, #17B9BE 41%, rgba(0,176,253,0) 100%)' }, { valueColor: 'rgba(255, 224, 77, 1)', barBg: 'linear-gradient( 270deg, #FFFFFF 0%, #FFE04D 2%, #F45A23 41%, rgba(244,90,35,0) 100%)' }, { valueColor: 'rgba(0, 255, 150, 1)', barBg: 'linear-gradient( 270deg, #FFFFFF 0%, #BAFA54 2%, #4EDE74 41%, rgba(85,223,113,0) 100%)' }, { valueColor: 'rgba(0, 176, 253, 1)', barBg: 'linear-gradient( 270deg, #FFFFFF 0%, #6DD2FF 2%, #00B0FD 41%, rgba(0,176,253,0) 100%)' }, { valueColor: 'rgba(0, 248, 255, 1)', barBg: 'linear-gradient( 270deg, #FFFFFF 0%, #00F8FF 2%, #17B9BE 41%, rgba(0,176,253,0) 100%)' }, ], list: [ { text: '工程學院', value: 0 }, { text: '土木工程學院', value: 0 }, { text: '程學院', value: 0 }, { text: '程學院', value: 0 }, { text: '資訊程學院', value: 0 }, ] } }, computed: { max() { let n = this.list[0].value this.list.forEach(item => { if (item.value - n > 0) n = item.value }) return n } }, created() { const dataChart = this.dataChart; // 大屏編輯器暴露的屬性 if (dataChart) { this.text = dataChart.text } }, } </script> <!-- console.log(this.dataChart) --> <style scoped> .ting-rank { } .ting-rank ul{ list-style: none; padding-left: 0; } .ting-rank ul li{ display: flex; align-items: center; /* background-color: RGBA(5, 35, 55, 1); */ margin-bottom: 16px; position: relative; padding: 0 10px; } .ting-rank ul li .index{ width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-family: DIN, DIN; font-weight: 500; font-size: 26px; color: #FFFFFF; line-height: 0px; text-shadow: 0px 2px 4px #002A40; text-align: left; font-style: normal; text-transform: none; background: linear-gradient( 180deg, #00B0FD 0%, #003F68 100%); box-shadow: -2px 1px 4px 1px #021223, inset 0px 2px 4px 1px rgba(255,255,255,0.45); } .ting-rank ul li .text{ position: absolute; top: 0;bottom: 0;left: 70px; display: flex; align-items: center; font-family: Microsoft YaHei, Microsoft YaHei; font-weight: 400; font-size: 18px; color: #F3F7FF; text-align: left; font-style: normal; text-transform: none; } .ting-rank ul li .bar-wrapper { flex: 1; height: 10px; background: linear-gradient( 90deg, rgba(16,58,96,0) 0%, #18588E 100%); border-radius: 0px 0px 0px 0px; } .ting-rank ul li .bar-wrapper .bar { width: 222px; height: 10px; background: linear-gradient( 270deg, #FFFFFF 0%, #00F8FF 2%, #17B9BE 41%, rgba(0,176,253,0) 100%); border-radius: 0px 0px 0px 0px; } .ting-rank ul li .value-wrapper { width: 60px; padding-left: 10px; display: flex; justify-content: space-between; color: rgba(0, 248, 255, 1); } .ting-rank ul li .value-wrapper .unit { width: 16px; height: 16px; font-family: MicrosoftYaHei, MicrosoftYaHei; font-weight: 400; font-size: 16px; color: #B9CCDF; text-align: left; font-style: normal; text-transform: none; } </style>