|
|
@@ -1,22 +1,25 @@
|
|
|
<template>
|
|
|
<div
|
|
|
- class="l-flex__fill block__box"
|
|
|
+ class="l-flex__fill u-releative"
|
|
|
:class="isCol? 'l-flex': 'l-flex--col'"
|
|
|
>
|
|
|
<status-wrapper
|
|
|
- v-if="list.length === 0"
|
|
|
+ v-if="items.length === 0"
|
|
|
class="l-flex__fill l-flex--row center"
|
|
|
/>
|
|
|
<template v-else>
|
|
|
- <template v-if="!isCol">
|
|
|
+ <template v-if="isCol">
|
|
|
+ <BarEcharts :items="items" />
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
<div
|
|
|
- v-for="item in progressData"
|
|
|
+ v-for="item in items"
|
|
|
:key="item.key"
|
|
|
class="l-flex__fill block"
|
|
|
>
|
|
|
- <div class="block__intro">
|
|
|
- <div class="block__name">{{ item.name }}</div>
|
|
|
- <div class="block__value">播放{{ item.value }}</div>
|
|
|
+ <div class="l-flex--row block__intro">
|
|
|
+ <div class="l-flex__fill c-siblint-item block__name u-ellipsis">{{ item.name }}</div>
|
|
|
+ <div class="l-flex__none c-siblint-item block__value">{{ item.value }}</div>
|
|
|
</div>
|
|
|
<div class="block__progress--outer">
|
|
|
<div
|
|
|
@@ -26,9 +29,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <template v-else>
|
|
|
- <BarEcharts :items="progressData" />
|
|
|
- </template>
|
|
|
</template>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -61,9 +61,9 @@ function formatSeconds (value) {
|
|
|
if (hourTime > 0) {
|
|
|
result = `${parseInt(hourTime)}小时${result}`
|
|
|
}
|
|
|
- console.log('result', result)
|
|
|
return result
|
|
|
}
|
|
|
+
|
|
|
export default {
|
|
|
name: 'TopRankChart',
|
|
|
components: {
|
|
|
@@ -75,51 +75,27 @@ export default {
|
|
|
default: () => []
|
|
|
},
|
|
|
isTime: {
|
|
|
- type: Boolean,
|
|
|
+ type: [Boolean, String],
|
|
|
default: false
|
|
|
},
|
|
|
isMoney: {
|
|
|
- type: Boolean,
|
|
|
+ type: [Boolean, String],
|
|
|
default: false
|
|
|
},
|
|
|
isCol: {
|
|
|
- type: Boolean,
|
|
|
+ type: [Boolean, String],
|
|
|
default: false
|
|
|
}
|
|
|
},
|
|
|
- data () {
|
|
|
- return {
|
|
|
- progressData: []
|
|
|
- }
|
|
|
- },
|
|
|
- watch: {
|
|
|
- list: {
|
|
|
- handler () {
|
|
|
- this.transform()
|
|
|
- },
|
|
|
- immediate: true
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- transform () {
|
|
|
- if (!this.list) {
|
|
|
- this.progressData = []
|
|
|
- return
|
|
|
- }
|
|
|
- this.progressData = this.list.slice()
|
|
|
- this.progressData = this.progressData
|
|
|
- .sort((a, b) => b.value - a.value)
|
|
|
- .slice(0, 5)
|
|
|
+ computed: {
|
|
|
+ items () {
|
|
|
let max = 0
|
|
|
- let total = this.progressData.reduce(
|
|
|
- (total, cur) => {
|
|
|
- max = Math.max(max, cur.value)
|
|
|
- return total + cur.value
|
|
|
- },
|
|
|
- 0
|
|
|
- )
|
|
|
+ let total = this.list.reduce((total, cur) => {
|
|
|
+ max = Math.max(max, cur.value)
|
|
|
+ return total + cur.value
|
|
|
+ }, 0)
|
|
|
total = Math.max(max, total *= 0.6)
|
|
|
- this.progressData = this.progressData.map(i => {
|
|
|
+ return this.list.map(i => {
|
|
|
const item = {
|
|
|
...i,
|
|
|
rate: `${(i.value * 100) / total}%`
|
|
|
@@ -137,101 +113,42 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.block__box{
|
|
|
- position: relative;
|
|
|
-}
|
|
|
-.block__col{
|
|
|
- z-index: 2;
|
|
|
-}
|
|
|
.block {
|
|
|
height: 20%;
|
|
|
padding-top: 20px;
|
|
|
+
|
|
|
&:nth-child(1) {
|
|
|
padding-top: 0;
|
|
|
}
|
|
|
+
|
|
|
&__intro {
|
|
|
- display: flex;
|
|
|
- justify-content: space-between;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
+
|
|
|
&__name {
|
|
|
- font-size: 30px;
|
|
|
color: #9ea9cd;
|
|
|
- line-height: 40px;
|
|
|
- text-align: center;
|
|
|
+ font-size: 30px;
|
|
|
}
|
|
|
+
|
|
|
&__value {
|
|
|
font-size: 30px;
|
|
|
- line-height: 40px;
|
|
|
}
|
|
|
+
|
|
|
&__progress--outer {
|
|
|
height: 20px;
|
|
|
position: relative;
|
|
|
background-color: #060920;
|
|
|
width: 100%;
|
|
|
- .block__progress--inner {
|
|
|
- position: absolute;
|
|
|
- width: 0;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- bottom: 0;
|
|
|
- background-color: #12A3FF;
|
|
|
- transition: all 1s;
|
|
|
- }
|
|
|
}
|
|
|
- &__introcol{
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- margin-top: 10px;
|
|
|
- }
|
|
|
- &__progress--outercol {
|
|
|
- height: 74%;
|
|
|
- position: relative;
|
|
|
- background-color: transparent;
|
|
|
- width: 64px;
|
|
|
- margin-left: 50%;
|
|
|
- transform: translateX(-50%);
|
|
|
- margin-top: 35px;
|
|
|
- .block__progress--innercol {
|
|
|
- position: absolute;
|
|
|
- width: 64px;
|
|
|
- left: 0%;
|
|
|
- bottom: 0;
|
|
|
- background-color: #12A3FF;
|
|
|
- transition: all 1s;
|
|
|
- }
|
|
|
- .block__top{
|
|
|
- position: absolute;
|
|
|
- left: 50%;
|
|
|
- transform: translateX(-50%);
|
|
|
- white-space: nowrap;
|
|
|
- margin-bottom: 10px;
|
|
|
- }
|
|
|
+
|
|
|
+ &__progress--inner {
|
|
|
+ position: absolute;
|
|
|
+ width: 0;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ bottom: 0;
|
|
|
+ background-color: #12A3FF;
|
|
|
+ transition: all 1s;
|
|
|
}
|
|
|
}
|
|
|
-.line{
|
|
|
- width: 100%;
|
|
|
- height: 1px;
|
|
|
- background-color: #313A5A;
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
-}
|
|
|
-.line1 {
|
|
|
- bottom: 18%;
|
|
|
-}
|
|
|
-.line2 {
|
|
|
- bottom: 33%;
|
|
|
-}
|
|
|
-.line3 {
|
|
|
- bottom: 48%;
|
|
|
-}
|
|
|
-.line4 {
|
|
|
- bottom: 63%;
|
|
|
-}
|
|
|
-.line5 {
|
|
|
- bottom: 78%;
|
|
|
-}
|
|
|
-.line6 {
|
|
|
- bottom: 92%;
|
|
|
-}
|
|
|
</style>
|