mirror of
https://gitee.com/dromara/go-view.git
synced 2025-06-30 08:39:15 +08:00
fix: 修复bug
This commit is contained in:
parent
796995f0d7
commit
4bb7a4ed22
@ -22,6 +22,7 @@ export const PieTypeObject = {
|
||||
const otherConfig = {
|
||||
// 轮播动画
|
||||
isCarousel: false,
|
||||
legendShowValue: false,
|
||||
}
|
||||
|
||||
const option = {
|
||||
@ -32,7 +33,10 @@ const option = {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
show: true,
|
||||
formatter: (name: string) => {
|
||||
return name
|
||||
}
|
||||
},
|
||||
dataset: { ...dataJson },
|
||||
series: [
|
||||
|
@ -7,6 +7,14 @@
|
||||
<!-- <n-select v-model:value="optionData.type" size="small" :options="fontWeightOptions" />-->
|
||||
<!-- </SettingItem>-->
|
||||
<!-- </SettingItemBox>-->
|
||||
<SettingItemBox name="图例" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.legendShowValue" size="small"></n-switch>
|
||||
<n-text>展示数值</n-text>
|
||||
</n-space>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="动画" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
|
@ -144,6 +144,25 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(() => props.chartConfig.option.legendShowValue, v => {
|
||||
if(v) {
|
||||
let k1 = props.chartConfig.option.dataset?.dimensions?.[0] || ''
|
||||
let k2 = props.chartConfig.option.dataset?.dimensions?.[1] || ''
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
let arr = props.chartConfig.option.dataset?.source || []
|
||||
let obj = arr.find((_: any) => _[k1] === name) || {}
|
||||
return `${name} ${obj[k2]}`
|
||||
}
|
||||
}
|
||||
else {
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
return name
|
||||
}
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
})
|
||||
|
||||
// const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: typeof dataJson) => {
|
||||
// clearPieInterval()
|
||||
// if (props.chartConfig.option.isCarousel) {
|
||||
|
@ -22,6 +22,7 @@ export const PieTypeObject = {
|
||||
const otherConfig = {
|
||||
// 轮播动画
|
||||
isCarousel: false,
|
||||
legendShowValue: false,
|
||||
}
|
||||
|
||||
const option = {
|
||||
@ -30,13 +31,16 @@ const option = {
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
let str = `${params.seriesName}<br/>${params.marker}${params.name}`
|
||||
return str
|
||||
}
|
||||
// formatter: (params: any) => {
|
||||
// let str = `${params.seriesName}<br/>${params.marker}${params.name}`
|
||||
// return str
|
||||
// }
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
show: true,
|
||||
formatter: (name: string) => {
|
||||
return name
|
||||
}
|
||||
},
|
||||
dataset: { ...dataJson },
|
||||
series: [
|
||||
|
@ -7,6 +7,14 @@
|
||||
<!-- <n-select v-model:value="optionData.type" size="small" :options="fontWeightOptions" />-->
|
||||
<!-- </SettingItem>-->
|
||||
<!-- </SettingItemBox>-->
|
||||
<SettingItemBox name="图例" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.legendShowValue" size="small"></n-switch>
|
||||
<n-text>展示数值</n-text>
|
||||
</n-space>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="动画" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
|
@ -155,13 +155,13 @@ const { vChartRef } = useChartCommonData(props.chartConfig, useChartEditStore)
|
||||
watch(
|
||||
() => props.chartConfig.option.dataset,
|
||||
(v) => {
|
||||
v.source.forEach((item: {[k: string]: any}) => {
|
||||
let k = v.dimensions[0]
|
||||
let k1 = v.dimensions[1]
|
||||
if(item[k].split(' ').length < 2) {
|
||||
item[k] += ` ${item[k1]}`
|
||||
}
|
||||
})
|
||||
// v.source.forEach((item: {[k: string]: any}) => {
|
||||
// let k = v.dimensions[0]
|
||||
// let k1 = v.dimensions[1]
|
||||
// if(item[k].split(' ').length < 2) {
|
||||
// item[k] += ` ${item[k1]}`
|
||||
// }
|
||||
// })
|
||||
if(vChartRef.value) {
|
||||
vChartRef.value.setOption({
|
||||
dataset: v
|
||||
@ -172,6 +172,24 @@ watch(
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
watch(() => props.chartConfig.option.legendShowValue, v => {
|
||||
if(v) {
|
||||
let k1 = props.chartConfig.option.dataset?.dimensions?.[0] || ''
|
||||
let k2 = props.chartConfig.option.dataset?.dimensions?.[1] || ''
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
let arr = props.chartConfig.option.dataset?.source || []
|
||||
let obj = arr.find((_: any) => _[k1] === name) || {}
|
||||
return `${name} ${obj[k2]}`
|
||||
}
|
||||
}
|
||||
else {
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
return name
|
||||
}
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
seriesDataMaxLength = dataJson.source.length
|
||||
|
@ -24,6 +24,7 @@ export const PieTypeObject = {
|
||||
const otherConfig = {
|
||||
// 轮播动画
|
||||
isCarousel: false,
|
||||
legendShowValue: false,
|
||||
}
|
||||
|
||||
const option = {
|
||||
@ -34,7 +35,10 @@ const option = {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
show: true
|
||||
show: true,
|
||||
formatter: (name: string) => {
|
||||
return name
|
||||
}
|
||||
},
|
||||
dataset: { ...dataJson },
|
||||
series: [
|
||||
|
@ -7,6 +7,14 @@
|
||||
<n-select v-model:value="optionData.type" size="small" :options="fontWeightOptions" />
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="图例" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
<n-switch v-model:value="optionData.legendShowValue" size="small"></n-switch>
|
||||
<n-text>展示数值</n-text>
|
||||
</n-space>
|
||||
</SettingItem>
|
||||
</SettingItemBox>
|
||||
<SettingItemBox name="动画" :alone="true">
|
||||
<SettingItem>
|
||||
<n-space>
|
||||
|
@ -147,6 +147,25 @@ watch(
|
||||
}
|
||||
)
|
||||
|
||||
watch(() => props.chartConfig.option.legendShowValue, v => {
|
||||
if(v) {
|
||||
let k1 = props.chartConfig.option.dataset?.dimensions?.[0] || ''
|
||||
let k2 = props.chartConfig.option.dataset?.dimensions?.[1] || ''
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
let arr = props.chartConfig.option.dataset?.source || []
|
||||
let obj = arr.find((_: any) => _[k1] === name) || {}
|
||||
return `${name} ${obj[k2]}`
|
||||
}
|
||||
}
|
||||
else {
|
||||
props.chartConfig.option.legend.formatter = (name: string) => {
|
||||
return name
|
||||
}
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
})
|
||||
|
||||
// const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: typeof dataJson) => {
|
||||
// clearPieInterval()
|
||||
// if (props.chartConfig.option.isCarousel) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user