fix:修复条形图问题

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

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

@ -199,9 +199,21 @@ export default {
} else { } else {
// g2plot // g2plot
const xAxis = config.setting.find(item => item.field === 'xField')?.value 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 => { 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() item[xAxis] = (item[xAxis]).toString()
} else if (config.chartType === 'Bar' && yAxis && typeof item[yAxis] === 'number') {
item[yAxis] = (item[yAxis]).toString()
} }
return item return item
}) })

Loading…
Cancel
Save