NEZ-1263 fix: Chart legend 匹配内容有误

This commit is contained in:
zhangyu
2021-11-17 17:27:14 +08:00
parent da71a64f14
commit c76c0511c9
9 changed files with 47 additions and 11 deletions

View File

@@ -1023,11 +1023,15 @@ export default {
if (/\{\{.+\}\}/.test(expression)) {
const labelValue = expression.replace(/(\{\{.+?\}\})/g, function (i) {
const label = i.substr(i.indexOf('{{') + 2, i.indexOf('}}') - i.indexOf('{{') - 2)
const reg = new RegExp(label + '=".+?"')
const reg = new RegExp(',' + label + '=".+?"')
const reg1 = new RegExp('{' + label + '=".+?"')
let value = null
if (reg.test(legend)) {
const find = legend.match(reg)[0]
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
} else if (reg1.test(legend)) {
const find = legend.match(reg1)[0]
value = find.substr(find.indexOf('"') + 1, find.lastIndexOf('"') - find.indexOf('"') - 1)
}
return value || label
})