🐛 Fix case like y=80%*x painting wrongly

This commit is contained in:
2025-09-14 14:46:09 +08:00
parent d26c29613b
commit d652df407f
4 changed files with 52 additions and 14 deletions

View File

@@ -54,6 +54,12 @@ class _GraphCardState extends State<GraphCard> {
(match) => '${match.group(1)}*${match.group(2)}',
);
// 在 % 和变量或数字之间插入乘号 (如 80%x -> 80%*x)
functionExpr = functionExpr.replaceAllMapped(
RegExp(r'%([a-zA-Z\d])'),
(match) => '%*${match.group(1)}',
);
// 解析表达式
final parser = Parser(functionExpr);
final expr = parser.parse();