From c685202f6caa17d357da3b90c397d40eec121a2f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 17:49:52 +0000 Subject: [PATCH 1/6] feat(xychart): add per-point text labels for line charts Allow annotating individual data points on xychart line plots with custom text labels. The syntax extends the existing data array format: line [540 "PaLM", 65 "LLaMA", 34 "Llama 2", 7 "Mistral"] Each number can optionally be followed by a quoted string label. Labels are rendered above (vertical) or to the right (horizontal) of the data point, using the line's stroke color. Backward-compatible: existing syntax without labels works unchanged. Addresses mermaid-js/mermaid#5326. https://claude.ai/code/session_01CgvREhkQ3tVYCagq1mHmjV --- demos/xychart.html | 20 ++ .../chartBuilder/components/plot/linePlot.ts | 52 ++++- .../xychart/chartBuilder/interfaces.ts | 1 + .../src/diagrams/xychart/parser/xychart.jison | 13 +- .../xychart/parser/xychart.jison.spec.ts | 188 +++++++++++++----- .../mermaid/src/diagrams/xychart/xychartDb.ts | 18 +- 6 files changed, 232 insertions(+), 60 deletions(-) diff --git a/demos/xychart.html b/demos/xychart.html index 570c8114b3c..bfc22c351e8 100644 --- a/demos/xychart.html +++ b/demos/xychart.html @@ -316,6 +316,26 @@

XY Charts demos with all theme config


+
+

Line chart with point labels

+
+    xychart
+      title "Smallest AI models scoring above 60% on MMLU"
+      x-axis "Date" ["Apr 2022", "Feb 2023", "Jul 2023", "Sep 2023", "Apr 2024"]
+      y-axis "Parameters (B)" 0 --> 600
+      line [540 "PaLM", 65 "LLaMA-65B", 34 "Llama 2 34B", 7 "Mistral 7B", 3.8 "Phi-3-mini"]
+    
+ +
+

Line chart with mixed labels (some points labeled, some not)

+
+    xychart
+      title "Quarterly Performance"
+      x-axis [Q1, Q2, Q3, Q4]
+      y-axis "Revenue ($M)" 0 --> 100
+      line [25 "Launch", 45, 72, 90 "Target Hit"]
+    
+