fix:修复条形图问题

main
liu.shiyi 1 year ago
parent 7dfb749f2c
commit 41b3249f28

@ -39,7 +39,6 @@ export default {
methods: {
//
getDataByExpression (config) {
console.log('getDataByExpression', this.dataset)
const result = new Function('dataset', 'computedDatas', this.config.expression)
config.customize.title = result(this.dataset, this.computedDatas)
//

@ -186,7 +186,7 @@ export default {
console.error(e)
}
}
if(config.chartType=='Treemap'){
if (config.chartType == 'Treemap') {
const xAxis = config.setting.find(item => item.field === 'xField')?.value
const listData = data.children.map(item => {
if (xAxis && typeof item[xAxis] === 'number') {
@ -194,14 +194,26 @@ export default {
}
return item
})
config.option.data={name:'root',children:[...listData]}
config.option.data = { name: 'root', children: [...listData] }
// console.log(config.option.data)
}else{
// g2plot
} else {
// g2plot
const xAxis = config.setting.find(item => item.field === 'xField')?.value
const yAxis = config.setting.find(item => item.field === 'yField')?.value
config.option.data = data?.map(item => {
if (xAxis && typeof item[xAxis] === 'number') {
// data
if (config.dataHandler) {
try {
// data
eval(config.dataHandler)
} catch (e) {
console.error(e)
}
}
if (config.chartType !== 'Bar' && xAxis && typeof item[xAxis] === 'number') {
item[xAxis] = (item[xAxis]).toString()
} else if (config.chartType === 'Bar' && yAxis && typeof item[yAxis] === 'number') {
item[yAxis] = (item[yAxis]).toString()
}
return item
})

Loading…
Cancel
Save