多维表功能完成

This commit is contained in:
aixianling
2023-10-08 18:16:51 +08:00
parent 4eeb00b093
commit 872e7afdd3
6 changed files with 841 additions and 909 deletions

View File

@@ -24,15 +24,7 @@
:key="`chart-${index}`" :key="`chart-${index}`"
:theme="theme" :theme="theme"
:data="values" :data="values"
:ops="chartList[data.config]"/> :ops="$echartTpls[data.config]"/>
<!-- <ai-q-map
v-else-if="currentType=='map'"
:area-id="data.areaId"
:markers="markers"
:is3d="data.is3D === '1'"
:limitArea="data.limitArea === '1'"
:is3dAround="data.is3dAround === '1'">
</ai-q-map> -->
<AiDvTable <AiDvTable
v-else-if="currentType === 'AiDvTable'" v-else-if="currentType === 'AiDvTable'"
:heigth="'100%'" :heigth="'100%'"
@@ -66,7 +58,7 @@
v-else-if="currentType === 'video'"/> v-else-if="currentType === 'video'"/>
<AiDvPartyOrg style="width: 100%; height: 100%;" v-else-if="currentType === 'partyOrg'" :instance="instance"/> <AiDvPartyOrg style="width: 100%; height: 100%;" v-else-if="currentType === 'partyOrg'" :instance="instance"/>
<!-- <ai-sprite v-else-if="/building/.test(currentType)" v-bind="data" is3D @init="mods[currentType]"/> --> <!-- <ai-sprite v-else-if="/building/.test(currentType)" v-bind="data" is3D @init="mods[currentType]"/> -->
<ai-dv-plot v-else-if="currentType=='plot'" :options="data.charts"/> <ai-dv-plot v-else-if="currentType=='plot'" :options="data.charts" :instance="instance"/>
</ai-dv-panel> </ai-dv-panel>
</div> </div>
</template> </template>
@@ -76,7 +68,6 @@ import {scrollBoard} from '@jiaminghi/data-view'
import Vue from "vue" import Vue from "vue"
import {mapState} from 'vuex' import {mapState} from 'vuex'
import AiDvMap from "./AiDvMap"; import AiDvMap from "./AiDvMap";
import chartList from './AiEchart/echartTpls'
import AiMonitor from "./AiMonitor/AiMonitor"; import AiMonitor from "./AiMonitor/AiMonitor";
import AiSwiper from './AiSwiper.vue' import AiSwiper from './AiSwiper.vue'
import AiDvDisplay from "./layout/AiDvDisplay/AiDvDisplay"; import AiDvDisplay from "./layout/AiDvDisplay/AiDvDisplay";
@@ -102,7 +93,6 @@ export default {
data() { data() {
return { return {
// mods, // mods,
chartList,
map: null, map: null,
lib: null, lib: null,
timer: null, timer: null,

View File

@@ -14,7 +14,7 @@ const install = function (Vue) {
}) })
Vue.prototype.MODEL = model Vue.prototype.MODEL = model
} }
Vue.prototype.$echartTpls = require("./AiEchart/echartTpls") Vue.prototype.$echartTpls = require("./AiEchart/echartTpls").default
// 遍历注册全局组件 // 遍历注册全局组件
let contexts = require.context('.', true, /[\\\/]Ai([^\\\/]+)\.vue$/); let contexts = require.context('.', true, /[\\\/]Ai([^\\\/]+)\.vue$/);
if (contexts) { if (contexts) {

View File

@@ -1,29 +1,89 @@
<template> <template>
<section class="AiDvPlot"> <section class="AiDvPlot">
<ai-select class="plotPicker" v-model="current" :select-list="charts" @change="handleChangeChart"/> <ai-select class="plotPicker" v-model="current" :select-list="charts" @change="handleChangeChart"/>
<div ref="DvPlot"/> <div class="plotChart" ref="DvPlot"/>
</section> </section>
</template> </template>
<script> <script>
import * as echarts from 'echarts'
import {DvCompData} from "../../../packages/bigscreen/designer/config";
export default { export default {
name: "AiDvPlot", name: "AiDvPlot",
props: { props: {
options: {default: () => []} options: {default: () => []},
instance: Function
}, },
data() { data() {
return { return {
current: 0 current: 0,
chart: null
} }
}, },
computed: { computed: {
charts: v => v.options.map((e, id) => ({id, label: e.title})), charts: v => v.options.map((e, id) => ({id, label: e.title})),
plot: v => v.options[v.current] plot: v => v.options[v.current],
tpl: v => v.$echartTpls[v.plot.chart]
}, },
methods: { methods: {
initChart() {
this.chart = echarts.init(this.$refs.DvPlot)
this.handleChangeChart()
},
handleChangeChart() { handleChangeChart() {
const series = Array(this.plot.dimensions.length - 1).fill(this.tpl.daemon)
this.chart.setOption({
tooltip: {},
xAxis: {
type: 'category', nameGap: 20, axisTick: false,
axisLabel: {
color: '#C3C4C4',
interval: 0,
},
axisLine: {
lineStyle: {
width: 1
}
}
},
// 声明一个 Y 轴,数值轴。
yAxis: {
nameGap: 23, minInterval: 1,
splitLine: {
lineStyle: {
type: 'dashed'
}
},
axisLabel: {color: '#C3C4C4'},
axisLine: {
lineStyle: {
color: '#C3C4C4'
}
}
},
grid: {
left: '0%',
right: '0%',
bottom: '0%',
top: '26px',
containLabel: true
}, series, ...this.tpl
})
this.getChartData()
},
getChartData() {
return new DvCompData(this.plot.dataType, this.plot, this.instance).getData().then(source => {
const dataset = {
source,
dimensions: this.plot.dimensions.filter(Boolean) || []
}
this.chart.setOption({dataset})
})
} }
}, },
mounted() {
this.$nextTick(this.initChart)
}
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -35,6 +95,7 @@ export default {
position: absolute; position: absolute;
right: 12px; right: 12px;
top: -10px; top: -10px;
z-index: 9;
.el-select { .el-select {
.el-input__inner { .el-input__inner {
@@ -48,5 +109,9 @@ export default {
} }
} }
} }
.plotChart {
height: 100%;
}
} }
</style> </style>

View File

@@ -55,6 +55,11 @@
<config-item label="接口地址" v-else-if="chart.dataType=='apiData'"> <config-item label="接口地址" v-else-if="chart.dataType=='apiData'">
<el-input size="mini" v-model="chart.api"/> <el-input size="mini" v-model="chart.api"/>
</config-item> </config-item>
<config-item label="数据维度" v-if="chart.dataType !== 'staticData'">
<code-editor v-model="chart.djson" lang="json" theme="github" width="100%" height="100"
placeholder="参照echarts配置数据维度,为一个数组,数组的第一个值为维度值"
@change="v=>chart.dimensions=JSON.parse(v)"/>
</config-item>
</ai-fold> </ai-fold>
<el-button type="text" icon="el-icon-plus" @click="options.charts.push({title:'新图表'})">添加图表</el-button> <el-button type="text" icon="el-icon-plus" @click="options.charts.push({title:'新图表'})">添加图表</el-button>
</template> </template>
@@ -159,6 +164,7 @@ import 'brace/theme/monokai';
import AiDialogBtn from "dui/packages/layout/AiDialogBtn.vue"; import AiDialogBtn from "dui/packages/layout/AiDialogBtn.vue";
import AiFold from "dui/packages/layout/AiFold.vue"; import AiFold from "dui/packages/layout/AiFold.vue";
import ChartPicker from "../chartPicker.vue"; import ChartPicker from "../chartPicker.vue";
import {DvCompData} from "../../config";
export default { export default {
name: 'dataConfig', name: 'dataConfig',
@@ -173,20 +179,7 @@ export default {
}, },
data() { data() {
return { return {
dataTypes: [ dataTypes: Object.entries(DvCompData.types).map(e => ({id: e[0], label: e[1]})),
{
id: 'staticData',
label: '静态数据'
},
{
id: 'dynamicData',
label: '动态数据'
},
{
id: 'apiData',
label: '接口'
}
],
json: "", json: "",
sourceDataId: '', sourceDataId: '',
sourceData: [], sourceData: [],
@@ -195,7 +188,6 @@ export default {
list: [], list: [],
showMapEditor: false, showMapEditor: false,
form: {}, form: {},
charts: Object.keys({}).map((label, id) => ({id, label}))
} }
}, },
computed: { computed: {

File diff suppressed because it is too large Load Diff

View File

@@ -59,7 +59,7 @@ export default {
legend = {textStyle: {color: '#fff', padding: [0, 0, 0, 8], fontSize: 14}, show: false}, legend = {textStyle: {color: '#fff', padding: [0, 0, 0, 8], fontSize: 14}, show: false},
series = data?.[0] ? Array(Object.keys(data?.[0]).length - 1).fill(1) series = data?.[0] ? Array(Object.keys(data?.[0]).length - 1).fill(1)
.map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : [] .map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : []
let ops = { return {
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
type: 'category', nameGap: 20, axisTick: false, type: 'category', nameGap: 20, axisTick: false,
@@ -84,7 +84,7 @@ export default {
type: 'dashed' type: 'dashed'
} }
}, },
axisLabel: { color: '#C3C4C4' }, axisLabel: {color: '#C3C4C4'},
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#C3C4C4' color: '#C3C4C4'
@@ -101,7 +101,6 @@ export default {
legend, series, ...options, legend, series, ...options,
color: colors color: colors
} }
return ops
}, },
grid() { grid() {
let {width, height} = this.chartOptions.grid || {} let {width, height} = this.chartOptions.grid || {}