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
nezha-nezha-fronted/nezha-fronted/src/components/chart/chart.vue

237 lines
7.1 KiB
Vue
Raw Normal View History

2021-11-19 09:40:21 +08:00
<template>
<div :style="chartInfo.param.showHeader ? '' : 'padding-top: 15px;'" class="nz-chart" :class="chartInfo.param.showHeader ? '' : 'no-header'" >
2021-12-02 21:46:07 +08:00
<loading :loading="loading"></loading>
2021-12-17 09:47:50 +08:00
<chart-no-data v-if="isNoData || isError"></chart-no-data>
<template v-else>
<chart-time-series
v-if="isTimeSeries(chartInfo.type)"
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-01 20:27:23 +08:00
:is-fullscreen="isFullscreen"
></chart-time-series>
2021-12-07 17:43:21 +08:00
<chart-pie
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
2021-12-07 17:43:21 +08:00
v-if="isChartPie(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
></chart-pie>
2021-12-08 10:57:58 +08:00
<chart-bar
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
2021-12-08 10:57:58 +08:00
v-if="isChartBar(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
></chart-bar>
2021-11-30 17:15:29 +08:00
<chartHexagon
:ref="'chart'+chartInfo.id"
v-if="isHexagonFigure(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
2021-11-30 17:15:29 +08:00
></chartHexagon>
<chart-url
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
v-if="isUrl(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
></chart-url>
<chart-text
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
v-if="isText(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
></chart-text>
<chart-treemap
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
v-if="isTreemap(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
></chart-treemap>
<chart-log
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
v-if="isLog(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
></chart-log>
<chart-stat
2021-12-10 16:18:18 +08:00
:ref="'chart' + chartInfo.id"
v-if="isStat(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-13 13:58:56 +08:00
:is-fullscreen="isFullscreen"
></chart-stat>
2021-12-13 13:58:56 +08:00
<chart-diagram
:ref="'chart' + chartInfo.id"
v-if="isDiagram(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:is-fullscreen="isFullscreen"
:chart-option="chartOption"
></chart-diagram>
2021-12-14 18:56:50 +08:00
<chartAutoCarousel
2021-12-13 17:07:41 +08:00
:ref="'chart' + chartInfo.id"
2021-12-14 18:56:50 +08:00
v-if="isAutoCarousel(chartInfo.type)"
2021-12-13 17:07:41 +08:00
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
2021-12-14 18:56:50 +08:00
:is-fullscreen="isFullscreen"
></chartAutoCarousel>
2021-12-15 12:11:13 +08:00
<chartMap
2021-12-13 20:54:01 +08:00
:ref="'chart' + chartInfo.id"
2021-12-15 12:11:13 +08:00
v-if="isMap(chartInfo.type)"
2021-12-13 20:54:01 +08:00
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
2021-12-15 12:11:13 +08:00
></chartMap>
2021-12-15 12:12:57 +08:00
<chart-asset-info
:ref="'chart' + chartInfo.id"
v-if="isAssetInfo(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
></chart-asset-info>
<chart-endpoint-info
:ref="'chart' + chartInfo.id"
v-if="isEndpointInfo(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
></chart-endpoint-info>
2021-12-15 17:55:56 +08:00
<chart-table
:ref="'chart' + chartInfo.id"
v-if="isTable(chartInfo.type)"
:chart-data="chartData"
:chart-info="chartInfo"
:chart-option="chartOption"
:is-fullscreen="isFullscreen"
></chart-table>
2021-12-13 17:07:41 +08:00
<chart-group
:ref="'chart' + chartInfo.id"
2021-12-16 19:15:32 +08:00
:from="from"
2021-12-13 17:07:41 +08:00
v-if="isGroup(chartInfo.type)"
:panelLock="panelLock"
:chart-data="chartData"
:chart-info="chartInfo"
:is-fullscreen="isFullscreen"
:chart-option="chartOption"
></chart-group>
</template>
</div>
2021-11-19 09:40:21 +08:00
</template>
<script>
2021-12-02 21:46:07 +08:00
import loading from '@/components/common/loading'
import chartAssetInfo from './chart/chartAssetInfo'
2021-12-13 20:54:01 +08:00
import chartAutoCarousel from './chart/chartAutoCarousel'
import chartBar from './chart/chartBar'
import chartClock from './chart/chartClock'
import chartDiagram from './chart/chartDiagram'
import chartEndpointInfo from './chart/chartEndpointInfo'
import chartGauge from './chart/chartGauge'
import chartGroup from './chart/chartGroup'
import chartLog from './chart/chartLog'
import chartNoData from './chart/chartNoData'
import chartPie from './chart/chartPie'
import chartStat from './chart/chartStat'
import chartTable from './chart/chartTable'
import chartText from './chart/chartText'
import chartTimeSeries from './chart/chartTimeSeries'
import chartTreemap from './chart/chartTreemap'
import chartUrl from './chart/chartUrl'
import chartValue from './chart/chartValue'
2021-11-30 16:39:21 +08:00
import chartHexagon from './chart/chartHexagon'
2021-12-15 12:11:13 +08:00
import chartMap from './chart/chartMap'
2021-12-15 17:55:56 +08:00
import { getOption, isTimeSeries, isHexagonFigure, isUrl, isText, isChartPie, isChartBar, isTreemap, isLog, isStat, isDiagram, isGroup, isAutoCarousel, isMap, isAssetInfo, isEndpointInfo, isTable } from './chart/tools'
import lodash from 'lodash'
2021-11-19 09:40:21 +08:00
export default {
name: 'chart',
components: {
2021-12-02 21:46:07 +08:00
loading,
chartAssetInfo,
2021-12-13 20:54:01 +08:00
chartAutoCarousel,
chartBar,
chartClock,
chartDiagram,
chartEndpointInfo,
chartGauge,
chartGroup,
chartLog,
chartNoData,
chartPie,
chartStat,
chartTable,
chartText,
chartTimeSeries,
chartTreemap,
chartUrl,
2021-11-30 16:39:21 +08:00
chartValue,
2021-12-15 12:11:13 +08:00
chartHexagon,
chartMap
},
props: {
chartInfo: Object,
chartData: [Object, Array, String], // 数据查询后传入chart组件chart组件内不查询只根据接传递的数据来渲染
2021-12-01 20:27:23 +08:00
customChartOption: Object, // 需要自定义echarts的option时传入非必须传入该值时仍需传对应格式的chartData
2021-12-02 21:46:07 +08:00
isFullscreen: Boolean,
2021-12-13 17:07:41 +08:00
loading: Boolean,
2021-12-16 19:15:32 +08:00
panelLock: Boolean,
2021-12-17 09:47:50 +08:00
from: String,
isError: Boolean
},
computed: {
isNoData () {
return lodash.isEmpty(this.chartData) && ['text', 'url'].indexOf(this.chartInfo.type) === -1
},
chartOption () {
if (this.customChartOption) {
return lodash.cloneDeep(this.customChartOption)
} else {
return getOption(this.chartInfo.type)
}
}
},
methods: {
2021-11-30 16:39:21 +08:00
isTimeSeries,
isHexagonFigure,
2021-12-07 17:43:21 +08:00
isChartPie,
2021-12-08 10:57:58 +08:00
isChartBar,
isUrl,
isText,
isTreemap,
isLog,
isStat,
2021-12-13 13:58:56 +08:00
isDiagram,
2021-12-13 17:07:41 +08:00
isGroup,
2021-12-13 20:54:01 +08:00
isAutoCarousel,
2021-12-15 12:12:57 +08:00
isAssetInfo,
isEndpointInfo,
2021-12-15 12:11:13 +08:00
isMap,
2021-12-15 17:55:56 +08:00
isTable,
2021-11-30 16:39:21 +08:00
resize () {
this.$refs['chart' + this.chartInfo.id].resize()
}
},
mounted () {
}
2021-11-19 09:40:21 +08:00
}
</script>