CN-38 feat: 添加 chart type 31

This commit is contained in:
zhangyu
2021-06-23 15:57:34 +08:00
parent 407e1c9c9f
commit becfb5b120
23 changed files with 334 additions and 51 deletions

View File

@@ -8,26 +8,27 @@
<slot name="operations"></slot>
</div>
</div>
<div class="cn-chart__body">
<div class="cn-chart__body" :class="{'pie-with-table': isPieWithTable}">
<slot></slot>
</div>
<div class="cn-chart__footer" v-if="layout.indexOf(layoutConstant.FOOTER) > -1">
<div class="cn-chart__footer" v-if="layout.indexOf(layoutConstant.FOOTER) > -1" :class="{'pie-with-table': isPieWithTable}">
<slot name="footer"></slot>
</div>
</div>
</template>
<script>
import { layoutConstant } from '@/components/charts/chart-options'
import { layoutConstant, isEchartsWithTable } from '@/components/charts/chart-options'
export default {
name: 'EchartsFrame',
props: {
layout: Array
layout: Array,
chartInfo: {}
},
setup () {
setup (props) {
return {
layoutConstant
layoutConstant,
isPieWithTable: isEchartsWithTable(props.chartInfo.type)
}
},
mounted () {
@@ -35,6 +36,9 @@ export default {
}
</script>
<style>
</style>
<style scoped>
.cn-panel .cn-chart__echarts .pie-with-table{
flex: 1;
padding: 10px;
}
</style>

View File

@@ -0,0 +1,103 @@
<template>
<el-table
v-loading="loading"
class="pie-table"
:data="tableData"
style="width: 100%;border: 1px solid #E7EAED"
:size="'mini'"
:height="'100%'">
<el-table-column type="expand" :min-width="'5%'">
<template #default="props">
<el-table
class="expand-table"
:data=" props.row.children"
style="width: 100%;"
:show-header="false"
:size="'mini'"
:height="'100%'">
<el-table-column
min-width="5%">
</el-table-column>
<el-table-column
v-for="(item, index) in tableTitles"
:key="index"
:min-width="item.width"
:label="item.label"
:prop="item.prop">
</el-table-column>
</el-table>
</template>
</el-table-column>
<el-table-column
v-for="(item, index) in tableTitles"
:key="index"
:min-width="item.width"
:label="item.label"
:prop="item.prop">
</el-table-column>
</el-table>
</template>
<script>
export default {
name: 'PieTable',
props: {
tableData: Array
},
watch: {
tableData: {
deep: true,
immediate: true,
handler (n) {
console.log(n)
}
}
},
data () {
return {
loading: false,
tableTitles: [
{
label: this.$t('chart.pieTable.domain'),
prop: 'domain',
width: '20%'
},
{
label: this.$t('chart.pieTable.sessions'),
prop: 'sessions',
width: '25%'
},
{
label: this.$t('chart.pieTable.packets'),
prop: 'packets',
width: '25%'
},
{
label: this.$t('chart.pieTable.bytes'),
prop: 'bytes',
width: '25%'
}
]
}
}
}
</script>
<style scoped>
/deep/ .el-table__expanded-cell[class*=cell]{
padding: 0;
}
.expand-table /deep/ .el-table__body .el-table__row:last-of-type td{
border: none;
}
.pie-table{
font-family: Roboto-Medium;
font-size: 14px;
color: #333333;
font-weight: 500;
}
.expand-table{
font-weight: 400;
color: #606266;
}
</style>

View File

@@ -15,16 +15,105 @@ const pieData = [
{ value: 4, name: 'sessions' },
{ value: 5, name: 'fqdn_category_name' },
{ value: 1, name: 'uniq_domain1' },
{ value: 2, name: 'bytes2' },
{ value: 3, name: 'packets3' },
{ value: 4, name: 'sessions4' },
{ value: 5, name: 'fqdn_category_name5' },
{ value: 1, name: 'uniq_domain6' },
{ value: 2, name: 'bytes7' },
{ value: 3, name: 'packets8' },
{ value: 4, name: 'sessions9' },
{ value: 5, name: 'fqdn_category_name10' }
{ value: 2, name: 'bytes1' },
{ value: 3, name: 'packets1' },
{ value: 4, name: 'sessions1' },
{ value: 5, name: 'fqdn_category_name1' }
// { value: 1, name: 'uniq_domain2' },
// { value: 2, name: 'bytes2' },
// { value: 3, name: 'packets2' },
// { value: 4, name: 'sessions2' },
// { value: 5, name: 'fqdn_category_name2' },
// { value: 1, name: 'uniq_domain3' },
// { value: 2, name: 'bytes3' },
// { value: 3, name: 'packets3' },
// { value: 4, name: 'sessions3' },
// { value: 5, name: 'fqdn_category_name3' },
// { value: 1, name: 'uniq_domain4' },
// { value: 2, name: 'bytes4' },
// { value: 3, name: 'packets4' },
// { value: 4, name: 'sessions4' },
// { value: 5, name: 'fqdn_category_name4' }
]
export const pieTableDatas = [
{
domain: '12306.com',
bytes: '170537133646',
packets: '123454646',
sessions: '26682',
children: [
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
}
]
},
{
domain: '12306.com',
bytes: '170537133646',
packets: '123454646',
sessions: '26682',
children: [
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
}
]
},
{
domain: '12306.com',
bytes: '170537133646',
packets: '123454646',
sessions: '26682',
children: [
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
},
{
domain: '192.168.36.120',
bytes: '170537133646',
packets: '123454646',
sessions: '26682'
}
]
}]
const line = {
xAxis: {
type: 'time'
@@ -141,18 +230,21 @@ const pieWithTable = {
},
legend: {
orient: 'vertical',
right: '0%',
type: 'plain',
right: '5%',
top: '30%',
height: '50%',
width: '40%',
icon: 'circle',
itemWidth: 10, // 设置宽度
itemHeight: 10, // 设置高度
itemGap: 20
},
series: [
{
type: 'pie',
radius: ['50%', '80%'],
center: ['30%', '50%'],
center: ['25%', '50%'],
data: pieData,
emphasis: {
itemStyle: {