feat:添加chartGroup的类型

This commit is contained in:
zhangyu
2021-12-13 17:07:41 +08:00
parent dbb21aa404
commit 7b101ad8a5
7 changed files with 83 additions and 25 deletions

View File

@@ -83,6 +83,15 @@
:is-fullscreen="isFullscreen" :is-fullscreen="isFullscreen"
:chart-option="chartOption" :chart-option="chartOption"
></chart-diagram> ></chart-diagram>
<chart-group
:ref="'chart' + chartInfo.id"
v-if="isGroup(chartInfo.type)"
:panelLock="panelLock"
:chart-data="chartData"
:chart-info="chartInfo"
:is-fullscreen="isFullscreen"
:chart-option="chartOption"
></chart-group>
</template> </template>
</div> </div>
</template> </template>
@@ -107,7 +116,7 @@ import chartTreemap from './chart/chartTreemap'
import chartUrl from './chart/chartUrl' import chartUrl from './chart/chartUrl'
import chartValue from './chart/chartValue' import chartValue from './chart/chartValue'
import chartHexagon from './chart/chartHexagon' import chartHexagon from './chart/chartHexagon'
import { getOption, isTimeSeries, isHexagonFigure, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram } from './chart/tools' import { getOption, isTimeSeries, isHexagonFigure, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup } from './chart/tools'
import lodash from 'lodash' import lodash from 'lodash'
export default { export default {
@@ -138,7 +147,8 @@ export default {
chartData: [Object, Array, String], // 数据查询后传入chart组件chart组件内不查询只根据接传递的数据来渲染 chartData: [Object, Array, String], // 数据查询后传入chart组件chart组件内不查询只根据接传递的数据来渲染
customChartOption: Object, // 需要自定义echarts的option时传入非必须传入该值时仍需传对应格式的chartData customChartOption: Object, // 需要自定义echarts的option时传入非必须传入该值时仍需传对应格式的chartData
isFullscreen: Boolean, isFullscreen: Boolean,
loading: Boolean loading: Boolean,
panelLock: Boolean
}, },
computed: { computed: {
isNoData () { isNoData () {
@@ -163,6 +173,7 @@ export default {
isLog, isLog,
isStat, isStat,
isDiagram, isDiagram,
isGroup,
resize () { resize () {
this.$refs['chart' + this.chartInfo.id].resize() this.$refs['chart' + this.chartInfo.id].resize()
} }

View File

@@ -1,29 +1,62 @@
<template> <template>
<chart-list <div style="width: 100%;height: 100%">
<chartList
ref="chartList" ref="chartList"
name="group"
:class="{'show-top':showTopBtn}" :class="{'show-top':showTopBtn}"
:data-list="dataList" :data-list="dataList"
:nowTimeType="nowTimeType" :nowTimeType="nowTimeType"
:from="fromRoute.panel" :from="fromRoute.panel"
:panel-lock="panelLock" :panel-lock="panelLock"
:isGroup="true"
:time-range="searchTime" :time-range="searchTime"
@edit-chart="editChart"
@on-refresh-time="refreshTime" @on-refresh-time="refreshTime"
@on-remove-chart="delChart"
@on-add-group-item-chart="addGroupItem"
:loading="chartListLoading" :loading="chartListLoading"
></chart-list> ></chartList>
</div>
</template> </template>
<script> <script>
import ChartList from '../../chart/chartList' import { fromRoute } from '@/components/common/js/constants'
import chartMixin from '@/components/chart/chartMixin'
import chartFormat from '@/components/chart/chartFormat'
export default { export default {
name: 'chart-group', name: 'chart-group',
components: { props: {
'chart-list': ChartList panelLock: Boolean
},
mixins: [chartMixin, chartFormat],
computed: {
searchTime () {
return this.$store.getters.getTimeRange
},
nowTimeType () {
return this.$store.getters.getNowTimeType
}
}, },
data () { data () {
showTopBtn: false return {
fromRoute,
dataList: [],
showTopBtn: false,
chartListLoading: false
}
},
methods: {
refreshTime () {
}
},
watch: {
chartData: {
immediate: true,
handler (n) {
console.log(n)
this.$nextTick(() => {
this.dataList = JSON.parse(JSON.stringify(n))
})
}
}
} }
} }
</script> </script>

View File

@@ -79,6 +79,9 @@ export function isStat (type) {
export function isDiagram (type) { export function isDiagram (type) {
return type === chartType.diagram return type === chartType.diagram
} }
export function isGroup (type) {
return type === chartType.group
}
export function initColor (colorNum = 20) { export function initColor (colorNum = 20) {
const colorList = [ const colorList = [

View File

@@ -1,5 +1,5 @@
<template> <template>
<div :id='`chartList${timestamp}`' class="chart-list" :loading="gridLayoutLoading"> <div :id='`chartList${(isGroup ? "Group" : "") + timestamp}`' class="chart-list" :loading="gridLayoutLoading">
<grid-layout <grid-layout
v-if="gridLayoutShow" v-if="gridLayoutShow"
:col-num="12" :col-num="12"
@@ -55,6 +55,7 @@
:ref="'chart-fullscreen' + fullscreen.chartInfo.id" :ref="'chart-fullscreen' + fullscreen.chartInfo.id"
:chart-info="fullscreen.chartInfo" :chart-info="fullscreen.chartInfo"
:is-fullscreen="true" :is-fullscreen="true"
:panelLock="panelLock"
:time-range="timeRange" :time-range="timeRange"
@showFullscreen="showFullscreen" @showFullscreen="showFullscreen"
></panel-chart> ></panel-chart>
@@ -75,6 +76,7 @@ export default {
obj: Object, obj: Object,
timeRange: Array, // 时间范围 timeRange: Array, // 时间范围
panelLock: { type: Boolean, default: true }, panelLock: { type: Boolean, default: true },
isGroup: { type: Boolean, default: false },
dataList: Array // 看板中所有图表信息 dataList: Array // 看板中所有图表信息
}, },
components: { components: {
@@ -104,7 +106,10 @@ export default {
}, },
methods: { methods: {
init () { init () {
const dom = document.getElementById(`chartList${this.timestamp}`) let dom = document.getElementById(`chartList${this.timestamp}`)
if (this.isGroup) {
dom = document.getElementById(`chartListGroup${this.timestamp}`)
}
if (dom) { if (dom) {
this.stepWidth = Math.floor(dom.offsetWidth / 12) this.stepWidth = Math.floor(dom.offsetWidth / 12)
const span = document.querySelector('.temp-dom') const span = document.querySelector('.temp-dom')

View File

@@ -15,6 +15,7 @@
ref="chart" ref="chart"
:chart-data="chartData" :chart-data="chartData"
:chart-info="chartInfo" :chart-info="chartInfo"
:panelLock="panelLock"
:is-fullscreen="isFullscreen" :is-fullscreen="isFullscreen"
:loading="loading" :loading="loading"
></chart> ></chart>
@@ -40,7 +41,8 @@ export default {
props: { props: {
chartInfo: Object, // 其中的param json串已转化为对象 chartInfo: Object, // 其中的param json串已转化为对象
timeRange: Array, // 时间范围 timeRange: Array, // 时间范围
isFullscreen: Boolean isFullscreen: Boolean,
panelLock: Boolean
}, },
data () { data () {
return { return {
@@ -141,6 +143,9 @@ export default {
if (this.chartInfo.type === 'diagram') { if (this.chartInfo.type === 'diagram') {
this.chartData = [this.chartInfo.param.topo] this.chartData = [this.chartInfo.param.topo]
} }
if (this.chartInfo.type === 'group') {
this.chartData = [...this.chartInfo.children]
}
break break
} }
} }

View File

@@ -84,6 +84,7 @@
<div class="box-content" v-loading="chartListLoading"> <div class="box-content" v-loading="chartListLoading">
<chart-list <chart-list
ref="chartList" ref="chartList"
name="panel"
:class="{'show-top':showTopBtn}" :class="{'show-top':showTopBtn}"
:data-list="dataList" :data-list="dataList"
:nowTimeType="nowTimeType" :nowTimeType="nowTimeType"
@@ -147,7 +148,6 @@
<script> <script>
import ChartBox from './chartBox' import ChartBox from './chartBox'
import chartRightBox from '@/components/common/rightBox/chart/chartRightBox' import chartRightBox from '@/components/common/rightBox/chart/chartRightBox'
import ChartList from '../../chart/chartList'
import bus from '../../../libs/bus' import bus from '../../../libs/bus'
import pickTime from '../../common/pickTime' import pickTime from '../../common/pickTime'
import selectPanel from '../../common/popBox/selectPanel' import selectPanel from '../../common/popBox/selectPanel'
@@ -271,7 +271,6 @@ export default {
}, },
components: { components: {
'chart-box': ChartBox, 'chart-box': ChartBox,
'chart-list': ChartList,
'pick-time': pickTime, 'pick-time': pickTime,
'panel-box': panelBox, 'panel-box': panelBox,
topToolMoreOptions, topToolMoreOptions,

View File

@@ -27,6 +27,7 @@ import Pagination from './components/common/pagination' // 引入全局分页组
import searchInput from './components/common/searchInput' // 搜索框组件 import searchInput from './components/common/searchInput' // 搜索框组件
import elementSet from './components/common/elementSet' // 自定义表头组件 import elementSet from './components/common/elementSet' // 自定义表头组件
import MyElSelect from './components/common/elSelect/MyElSelect' import MyElSelect from './components/common/elSelect/MyElSelect'
import chartList from '@/components/chart/chartList.vue' // 全局引入 chartList 组件 防止 chart-group爆粗
import loading from '@/components/common/loading' import loading from '@/components/common/loading'
import pickTime from '@/components/common/pickTime' import pickTime from '@/components/common/pickTime'
@@ -54,6 +55,7 @@ Vue.component('loading', loading)
Vue.component('pick-time', pickTime) Vue.component('pick-time', pickTime)
Vue.component('myDatePicker', myDatePicker) Vue.component('myDatePicker', myDatePicker)
Vue.component('nzDataList', nzDataList) Vue.component('nzDataList', nzDataList)
Vue.component('chartList', chartList)
Vue.prototype.$axios = axios Vue.prototype.$axios = axios
Vue.prototype.$post = post Vue.prototype.$post = post