This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cyber-narrator-cn-ui/src/components/charts/StatisticsLegend.vue

118 lines
2.7 KiB
Vue
Raw Normal View History

2021-07-05 22:58:12 +08:00
<template>
<div class="chart__legend">
<div class="chart__table-top table-below-box">
<div class="table__below-color"></div>
<div class="table__below-title">Name</div>
<div class="table__below-statistics">Avg</div>
<div class="table__below-statistics">Max</div>
</div>
<div class="chart__table-below">
<div v-for="(item, index) in data" :key="index" class="table-below-box" :class="{'table-below-box--inactivated': !item.active}" @click="toggleLegend(index)">
2021-07-09 21:58:49 +08:00
<div class="table__below-color"><div :style="{backgroundColor: getChartColor(index)}"></div></div>
<div class="table__below-title" :title="item.legend">{{item.legend}}</div>
<div class="table__below-statistics" :title="item.aggregation.avg">{{unitConvert(item.aggregation.avg, chartInfo.params.unitType).join(' ')}}</div>
<div class="table__below-statistics" :title="item.aggregation.max">{{unitConvert(item.aggregation.max, chartInfo.params.unitType).join(' ')}}</div>
</div>
2021-07-08 08:57:29 +08:00
</div>
</div>
2021-07-05 22:58:12 +08:00
</template>
<script>
2021-07-08 08:57:29 +08:00
import { getChartColor } from '@/components/charts/chart-options'
import unitConvert from '@/utils/unit-convert'
2021-07-05 22:58:12 +08:00
export default {
name: 'StatisticsLegend',
props: {
data: Array,
chartInfo: Object
2021-07-05 22:58:12 +08:00
},
methods: {
toggleLegend (index) {
this.$emit('toggleLegend', index)
}
},
2021-07-08 08:57:29 +08:00
setup () {
return {
getChartColor,
unitConvert
}
2021-07-05 22:58:12 +08:00
}
}
2021-07-08 08:57:29 +08:00
2021-07-05 22:58:12 +08:00
</script>
<style lang="scss" scoped>
2021-07-09 21:58:49 +08:00
.chart__legend {
2021-07-10 11:18:40 +08:00
width: calc(100% - 40px);
2021-07-08 16:23:11 +08:00
border: 1px solid #E7EAED;
2021-07-10 11:07:54 +08:00
color: #5f6368;
2021-07-08 08:57:29 +08:00
margin: auto;
margin-bottom: 15px;
2021-07-08 08:57:29 +08:00
}
2021-07-09 21:58:49 +08:00
.chart__table-top {
2021-07-10 11:07:54 +08:00
width: 100%;
2021-07-08 16:23:11 +08:00
height: 30px;
2021-07-10 11:07:54 +08:00
border-bottom: #E7EAED 1px solid;
display: flex;
2021-07-10 11:07:54 +08:00
div {
font-size: 13px;
line-height: 28px;
color: $--color-primary;
}
2021-07-08 08:57:29 +08:00
}
2021-07-09 21:58:49 +08:00
.chart__table-below {
height: 240px;
2021-07-10 11:07:54 +08:00
width: 100%;
2021-07-09 21:58:49 +08:00
font-size: 13px;
}
.table-below-box {
width: 100%;
display: flex;
align-items: center;
line-height: 24px;
}
.table-below-box:hover {
background-color: #f9f9f9;
border: 0;
color: #383838;
}
.table__below-color {
width: 27px;
height: 7px;
flex-shrink: 0;
padding-left: 10px;
2021-07-09 21:58:49 +08:00
div {
height: 100%;
width: 100%;
border-radius: 24%;
}
}
.table__below-title {
padding: 0 6px;
flex-shrink: 1;
flex-grow: 1;
overflow: hidden;
min-width: 200px;
text-overflow: ellipsis;
white-space: nowrap;
}
.table__below-statistics {
width: 80px;
flex-shrink: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.table-below-box:not(.chart__table-top) {
cursor: pointer;
}
.table-below-box.table-below-box--inactivated {
color: #ccc;
.table__below-color div {
background-color: #ccc !important;
}
}
</style>