You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2025/02/24 06:40:29 UTC

(echarts-from-mermaid) branch main updated: feat: update xychart

This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/echarts-from-mermaid.git


The following commit(s) were added to refs/heads/main by this push:
     new 979b8bd  feat: update xychart
979b8bd is described below

commit 979b8bd6f541053a326ca9245d046dce300e5fea
Author: Ovilia <zw...@gmail.com>
AuthorDate: Mon Feb 24 14:40:15 2025 +0800

    feat: update xychart
---
 src/charts/mermaid/xychart.ts | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/charts/mermaid/xychart.ts b/src/charts/mermaid/xychart.ts
index 60a77aa..0432527 100644
--- a/src/charts/mermaid/xychart.ts
+++ b/src/charts/mermaid/xychart.ts
@@ -51,13 +51,26 @@ export class XYChart extends BaseChart {
         continue;
       }
 
-      const dataMatch = line.match(/^\s*(\w+)\s+([0-9\s.]+)/);
+      const dataMatch = line.match(/^\s*(\w+)\s*$/);
       if (dataMatch) {
         currentSeries = {
           type: dataMatch[1],
-          data: dataMatch[2].trim().split(/\s+/).map(Number),
+          data: [],
         };
         result.series.push(currentSeries);
+        continue;
+      }
+
+      // 处理数据点
+      if (currentSeries) {
+        const pointMatch = line.match(
+          /^\s*(\d+(?:\.\d+)?),(\d+(?:\.\d+)?)\s*$/
+        );
+        if (pointMatch) {
+          const x = Number(pointMatch[1]);
+          const y = Number(pointMatch[2]);
+          currentSeries.data.push(y);
+        }
       }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org