fix: 抽取修改别名方法为全局 修改正则
This commit is contained in:
@@ -864,3 +864,21 @@ export function formatScientificNotation (value, dot = 2) {
|
||||
return getTdDom(dom.parentElement);
|
||||
}
|
||||
} */
|
||||
/* 处理legend的别名 */
|
||||
export function dealLegendAlias (legend, expression) {
|
||||
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('\\b' + 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)
|
||||
}
|
||||
return value || label
|
||||
})
|
||||
return labelValue
|
||||
} else {
|
||||
return expression
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user