联动表问题修复

This commit is contained in:
aixianling
2023-10-09 20:08:00 +08:00
parent 6f6dc79702
commit cec6ccc78a
4 changed files with 52 additions and 39 deletions

View File

@@ -39,10 +39,11 @@ export default {
}, },
labelLine: {}, labelLine: {},
labelLayout: function (params) { labelLayout: function (params) {
let points = params.labelLinePoints, let points = params.labelLinePoints
isLeft = points[2][0] < points[1][0] if (points) {
points[2][0] = const isLeft = points[2][0] < points[1][0]
points[2][0] + (params.labelRect.width + 4) * (isLeft ? -1 : 1) points[2][0] += (params.labelRect.width + 4) * (isLeft ? -1 : 1)
}
return { return {
labelLinePoints: points labelLinePoints: points
} }
@@ -65,32 +66,32 @@ export default {
return t + Number(Object.values(e)?.[1] || 0) return t + Number(Object.values(e)?.[1] || 0)
}, 0) }, 0)
return h( return h(
"div", "div",
{ {
style: { style: {
height: "162px", height: "162px",
width: "162px", width: "162px",
color: "#8BCCFF", color: "#8BCCFF",
left: "50%", left: "50%",
top: "50%", top: "50%",
display: "flex", display: "flex",
alignItems: "center", alignItems: "center",
justifyContent: "center", justifyContent: "center",
flexDirection: "column", flexDirection: "column",
position: "absolute", position: "absolute",
transform: "translate(-50%,-50%)", transform: "translate(-50%,-50%)",
backgroundImage: `url('https://cdn.cunwuyun.cn/dvcp/dv/tpl/pie2Circle.png')`, backgroundImage: `url('https://cdn.cunwuyun.cn/dvcp/dv/tpl/pie2Circle.png')`,
backgroundPosition: "center" backgroundPosition: "center"
} }
}, },
[ [
h( h(
"span", "span",
{style: {fontSize: "28px", color: "#fff", fontFamily: "DIN"}}, {style: {fontSize: "28px", color: "#fff", fontFamily: "DIN"}},
formatNum(total) formatNum(total)
), ),
h("span", null, "总量") h("span", null, "总量")
] ]
) )
} }
} }

View File

@@ -31,7 +31,7 @@ export default {
this.handleChangeChart() this.handleChangeChart()
}, },
handleChangeChart() { handleChangeChart() {
const series = Array(this.plot.dimensions.length - 1).fill(this.tpl.daemon) const series = this.tpl.series || Array(this.plot.dimensions.length - 1).fill(this.tpl.daemon)
this.chart.setOption({ this.chart.setOption({
tooltip: {}, tooltip: {},
xAxis: { xAxis: {
@@ -73,11 +73,20 @@ export default {
}, },
getChartData() { getChartData() {
return new DvCompData(this.plot.dataType, this.plot, this.instance).getData().then(source => { return new DvCompData(this.plot.dataType, this.plot, this.instance).getData().then(source => {
const dataset = { if (this.tpl.series?.type == 'pie') {
source, let data
dimensions: this.plot.dimensions.filter(Boolean) || [] if (source?.length == 1) {
data = this.plot.dimensions.filter(Boolean).map(name => ({name, value: source[0][name]}))
} else {
const ds = this.plot.dimensions.filter(Boolean)
data = source.map(e => ({name: e[ds[0]], value: e[ds[1]]}))
}
this.chart.setOption({series: {data}})
} else {
const dataset = {source}
dataset.dimensions = this.plot.dimensions.filter(Boolean) || []
this.chart.setOption({dataset})
} }
this.chart.setOption({dataset})
}) })
} }
}, },

View File

@@ -76,7 +76,7 @@ export default {
display: flex; display: flex;
position: relative; position: relative;
align-items: center; align-items: center;
backdrop-filter: blur(1px); backdrop-filter: blur(5px);
.right { .right {
min-width: 90px; min-width: 90px;

View File

@@ -24,7 +24,7 @@
</ai-dialog-btn> </ai-dialog-btn>
</ai-fold> </ai-fold>
</template> </template>
<template v-else-if="options.type=='plot'"> <template v-else-if="isPlot">
<ai-fold v-for="(chart,i) in options.charts" :key="i"> <ai-fold v-for="(chart,i) in options.charts" :key="i">
<div slot="title" class="flex w100"> <div slot="title" class="flex w100">
<span class="layoutTitle fill" v-text="chart.title"/> <span class="layoutTitle fill" v-text="chart.title"/>
@@ -36,7 +36,7 @@
<config-item label="图表模板"> <config-item label="图表模板">
<chart-picker v-model="chart.chart"/> <chart-picker v-model="chart.chart"/>
</config-item> </config-item>
<datasource-picker v-model="chart.ds" :instance="instance" <datasource-picker v-model="chart.ds" :instance="instance" class="mar-b10"
@input="chart={...chart,...chart.ds},$emit('change',options)"/> @input="chart={...chart,...chart.ds},$emit('change',options)"/>
<config-item label="数据维度" v-if="chart.dataType !== 'staticData'"> <config-item label="数据维度" v-if="chart.dataType !== 'staticData'">
<code-editor v-model="chart.djson" lang="json" theme="github" width="100%" height="100" <code-editor v-model="chart.djson" lang="json" theme="github" width="100%" height="100"
@@ -165,7 +165,8 @@ export default {
}, },
computed: { computed: {
markers: v => v.options.staticData?.markers || [], markers: v => v.options.staticData?.markers || [],
isTable: v => v.options.type == 'table' isTable: v => v.options.type == 'table',
isPlot: v => v.options.type == 'plot'
}, },
components: { components: {
DatasourcePicker, DatasourcePicker,
@@ -182,6 +183,8 @@ export default {
this.$emit("change", values) this.$emit("change", values)
} else if (this.isTable) { } else if (this.isTable) {
this.json = JSON.stringify(this.options.tableConfig) this.json = JSON.stringify(this.options.tableConfig)
} else if (this.isPlot) {
this.options.charts = this.options.charts.map(e => ({...e, ds: e}))
} }
}, },
mounted() { mounted() {