Skip to content

Commit b2d104d

Browse files
2 parents 9ddb90f + cb842d0 commit b2d104d

49 files changed

Lines changed: 6032 additions & 619 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ChartForgeX.Examples/ChartForgeX.Examples.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<ItemGroup>
1111
<ProjectReference Include="..\ChartForgeX\ChartForgeX.csproj" />
1212
<ProjectReference Include="..\ChartForgeX.Interactivity.Html\ChartForgeX.Interactivity.Html.csproj" />
13+
<ProjectReference Include="..\ChartForgeX.Markup\ChartForgeX.Markup.csproj" />
1314
</ItemGroup>
1415
</Project>

ChartForgeX.Examples/GalleryWriter.Catalog.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ public static partial class GalleryWriter {
148148
"service-dependency",
149149
"icon-palette",
150150
"icon-stencil-browser"),
151+
new(
152+
"Native Markup",
153+
"ChartForgeX v1 markup fences parsed through the public VisualMarkupParser artifact pipeline.",
154+
"markup-chart-release-trend",
155+
"markup-flow-approval",
156+
"markup-sequence-incident",
157+
"markup-timeline-release-plan",
158+
"markup-table-release-gates",
159+
"markup-topology-service-map"),
151160
new(
152161
"Topology Focus Views",
153162
"Focused topology variants for regional drilldowns, critical views, domain-controller filters, offenders, compact service maps, and dependency neighborhoods.",
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
using System.Text;
2+
using ChartForgeX.Markup;
3+
using ChartForgeX.VisualArtifacts;
4+
5+
/// <summary>
6+
/// Writes examples generated from ChartForgeX v1 markup fences.
7+
/// </summary>
8+
internal static class MarkupExamples {
9+
public static void Write(string output) {
10+
foreach (var example in Examples) SaveExample(output, example);
11+
}
12+
13+
private static void SaveExample(string output, MarkupExample example) {
14+
var parser = new VisualMarkupParser();
15+
var result = parser.Parse(example.Source);
16+
if (result.HasErrors || result.Artifacts.Count != 1) {
17+
var diagnostics = string.Join(Environment.NewLine, result.Diagnostics.Select(diagnostic => diagnostic.Line.ToString(System.Globalization.CultureInfo.InvariantCulture) + ": " + diagnostic.Severity + ": " + diagnostic.Message));
18+
throw new InvalidOperationException("Markup example '" + example.Name + "' did not produce exactly one artifact." + Environment.NewLine + diagnostics);
19+
}
20+
21+
var artifact = result.Artifacts[0];
22+
artifact.SaveSvg(Path.Combine(output, example.Name + ".svg"));
23+
artifact.SaveHtml(Path.Combine(output, example.Name + ".html"));
24+
artifact.SavePng(Path.Combine(output, example.Name + ".png"));
25+
WriteMarkupSource(output, example.Name, example.Source);
26+
WriteCSharpSource(output, example);
27+
}
28+
29+
private static void WriteMarkupSource(string output, string name, string source) =>
30+
File.WriteAllText(Path.Combine(output, name + ".cfx.md"), Normalize(source), Encoding.UTF8);
31+
32+
private static void WriteCSharpSource(string output, MarkupExample example) {
33+
var code = "using System;\n" +
34+
"using System.Linq;\n" +
35+
"using ChartForgeX.Markup;\n" +
36+
"using ChartForgeX.VisualArtifacts;\n\n" +
37+
"var markdown = @\"" + Normalize(example.Source).Replace("\"", "\"\"", StringComparison.Ordinal) + "\";\n\n" +
38+
"var result = new VisualMarkupParser().Parse(markdown);\n" +
39+
"if (result.HasErrors) {\n" +
40+
" throw new InvalidOperationException(string.Join(Environment.NewLine, result.Diagnostics));\n" +
41+
"}\n\n" +
42+
"var artifact = result.Artifacts.Single();\n" +
43+
"artifact.SaveSvg(\"" + example.Name + ".svg\");\n" +
44+
"artifact.SavePng(\"" + example.Name + ".png\");\n" +
45+
"artifact.SaveHtml(\"" + example.Name + ".html\");\n";
46+
File.WriteAllText(Path.Combine(output, example.Name + ".csharp.txt"), code.Replace("\r\n", "\n"), Encoding.UTF8);
47+
}
48+
49+
private static string Normalize(string source) => source.Replace("\r\n", "\n").Trim() + "\n";
50+
51+
private static readonly MarkupExample[] Examples = {
52+
new(
53+
"markup-chart-release-trend",
54+
"""
55+
```chartforgex chart v1
56+
id release-trend
57+
title Release Readiness Trend
58+
subtitle Multi-series chart parsed from native v1 markup
59+
type smooth-line
60+
size 920x520
61+
labels Intake, Build, Test, Package, Publish
62+
63+
series Ready type smoothline values 34 48 62 74 88 color #2563EB
64+
series Blocked type smoothline values 18 14 11 7 4 color #DC2626
65+
annotation hline 80 "ship gate" color=#059669
66+
```
67+
"""),
68+
new(
69+
"markup-flow-approval",
70+
"""
71+
```chartforgex flow v1
72+
id approval-flow
73+
title Approval Flow
74+
subtitle FlowArtifact parsed from native v1 markup, statically previewed through topology
75+
size 1120x620
76+
layout layered
77+
direction left-to-right
78+
79+
lanes:
80+
| id | label | status |
81+
| --- | --- | --- |
82+
| author | Author | positive |
83+
| review | Review | warning |
84+
| release | Release | neutral |
85+
86+
steps:
87+
| id | label | kind | lane | status | subtitle | badge |
88+
| --- | --- | --- | --- | --- | --- | --- |
89+
| draft | Draft change | start | author | positive | C# or markdown source | 1 |
90+
| validate | Validate contract | process | review | positive | Parser plus render checks | 2 |
91+
| approve | Approved? | decision | review | warning | Human gate | ? |
92+
| publish | Publish package | end | release | positive | Release artifact | 3 |
93+
94+
connectors:
95+
| from | to | label | kind | status |
96+
| --- | --- | --- | --- | --- |
97+
| draft | validate | submit | flow | positive |
98+
| validate | approve | evidence | dependency | positive |
99+
| approve | publish | yes | flow | positive |
100+
| approve | draft | changes | retry | warning |
101+
```
102+
"""),
103+
new(
104+
"markup-sequence-incident",
105+
"""
106+
```chartforgex sequence v1
107+
id incident-sequence
108+
title Incident Sequence
109+
subtitle SequenceArtifact parsed from native v1 markup
110+
size 960x560
111+
112+
participants:
113+
| id | label | kind |
114+
| --- | --- | --- |
115+
| user | User | actor |
116+
| api | API | participant |
117+
| db | Database | database |
118+
119+
messages:
120+
| from | to | text | style | activate |
121+
| --- | --- | --- | --- | --- |
122+
| user | api | Submit request | solid | true |
123+
| api | db | Store event | dashed | false |
124+
| db | api | Stored | dashed | false |
125+
| api | user | Accepted | solid | false |
126+
127+
notes:
128+
| placement | participant | text | step |
129+
| --- | --- | --- | --- |
130+
| rightOf | api | Processing and validation | 1 |
131+
132+
blocks:
133+
| kind | text | start | end |
134+
| --- | --- | --- | --- |
135+
| loop | Retry on transient failure | 0 | 2 |
136+
```
137+
"""),
138+
new(
139+
"markup-timeline-release-plan",
140+
"""
141+
```chartforgex timeline v1
142+
id release-plan
143+
title Release Plan
144+
subtitle Timeline/Gantt chart parsed from native v1 markup
145+
type gantt
146+
size 980x560
147+
today 2026-02-12
148+
149+
task Design 2026-01-05 2026-01-18 progress=1 color=#2563EB
150+
task Implement 2026-01-15 2026-02-14 progress=0.72 dependsOn=0 color=#14B8A6
151+
task Validate 2026-02-10 2026-02-28 progress=0.35 dependsOn=1 color=#F59E0B
152+
milestone Release 2026-03-05 dependsOn=2 color=#059669
153+
```
154+
"""),
155+
new(
156+
"markup-table-release-gates",
157+
"""
158+
```chartforgex table v1
159+
id release-gates
160+
title Release Gates
161+
subtitle TableArtifact parsed from native v1 markup with typed columns
162+
capabilities sort filter export
163+
164+
columns:
165+
| id | label | type | alignment |
166+
| --- | --- | --- | --- |
167+
| gate | Gate | text | left |
168+
| owner | Owner | text | left |
169+
| status | Status | status | center |
170+
| evidence | Evidence | text | left |
171+
172+
rows:
173+
| gate | owner | status | evidence |
174+
| --- | --- | --- | --- |
175+
| API grammar | Markup | positive | v1 reference and parser tests |
176+
| Static output | Core | positive | SVG and PNG parity |
177+
| Package smoke | Release | warning | Build.ps1 release gate |
178+
```
179+
"""),
180+
new(
181+
"markup-topology-service-map",
182+
"""
183+
```chartforgex topology v1
184+
id service-map
185+
title Service Map
186+
subtitle TopologyChart parsed from native v1 markup
187+
viewport 1120x620
188+
layout layered left-to-right
189+
190+
groups:
191+
| id | label | status |
192+
| --- | --- | --- |
193+
| edge | Edge | healthy |
194+
| core | Core | warning |
195+
| data | Data | healthy |
196+
197+
nodes:
198+
| id | label | kind | status | group | subtitle | badge |
199+
| --- | --- | --- | --- | --- | --- | --- |
200+
| portal | Portal | application | healthy | edge | Public entry | TLS |
201+
| api | API | service | warning | core | Backpressure watched | P95 |
202+
| worker | Worker | process | healthy | core | Queue consumer | 4 |
203+
| db | Database | database | healthy | data | Primary store | HA |
204+
205+
edges:
206+
| from | to | label | kind | status |
207+
| --- | --- | --- | --- | --- |
208+
| portal | api | HTTPS | data-flow | healthy |
209+
| api | worker | async | dependency | warning |
210+
| worker | db | write | data-flow | healthy |
211+
| api | db | read | data-flow | healthy |
212+
```
213+
""")
214+
};
215+
216+
private readonly struct MarkupExample {
217+
public MarkupExample(string name, string source) {
218+
Name = name;
219+
Source = source;
220+
}
221+
222+
public string Name { get; }
223+
public string Source { get; }
224+
}
225+
}

ChartForgeX.Examples/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void SaveGrid(ChartGrid grid, string name) {
129129

130130
SaveChart(heatmap, "control-coverage-heatmap-dark");
131131
MapExamples.Write(output, DemoPngOutputScale, ExampleProgramOptions.HasArg(args, "--include-external-map-examples"));
132-
if (!ExampleProgramOptions.HasArg(args, "--skip-topology")) TopologyExamples.Write(output);
132+
if (!ExampleProgramOptions.HasArg(args, "--skip-topology")) TopologyExamples.Write(output); MarkupExamples.Write(output);
133133

134134
var gauge = Chart.Create()
135135
.WithTitle("Security Posture Score")

ChartForgeX.Examples/visual-baseline.json

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,102 @@
12971297
"maxEdgeInkPixels": 0
12981298
}
12991299
},
1300+
{
1301+
"name": "markup-chart-release-trend",
1302+
"width": 920,
1303+
"height": 520,
1304+
"svg": {
1305+
"minVisualNodes": 37,
1306+
"maxClippedTextNodes": 0,
1307+
"maxNearEdgeTextNodes": 0
1308+
},
1309+
"png": {
1310+
"outputScale": 1,
1311+
"minVisiblePixels": 223391,
1312+
"minDistinctColors": 1451,
1313+
"maxEdgeInkPixels": 0
1314+
}
1315+
},
1316+
{
1317+
"name": "markup-flow-approval",
1318+
"width": 1120,
1319+
"height": 712,
1320+
"svg": {
1321+
"minVisualNodes": 40,
1322+
"maxClippedTextNodes": 0,
1323+
"maxNearEdgeTextNodes": 0
1324+
},
1325+
"png": {
1326+
"outputScale": 1,
1327+
"minVisiblePixels": 398720,
1328+
"minDistinctColors": 1012,
1329+
"maxEdgeInkPixels": 0
1330+
}
1331+
},
1332+
{
1333+
"name": "markup-sequence-incident",
1334+
"width": 960,
1335+
"height": 560,
1336+
"svg": {
1337+
"minVisualNodes": 13,
1338+
"maxClippedTextNodes": 0,
1339+
"maxNearEdgeTextNodes": 0
1340+
},
1341+
"png": {
1342+
"outputScale": 1,
1343+
"minVisiblePixels": 268800,
1344+
"minDistinctColors": 893,
1345+
"maxEdgeInkPixels": 0
1346+
}
1347+
},
1348+
{
1349+
"name": "markup-table-release-gates",
1350+
"width": 760,
1351+
"height": 360,
1352+
"svg": {
1353+
"minVisualNodes": 13,
1354+
"maxClippedTextNodes": 0,
1355+
"maxNearEdgeTextNodes": 0
1356+
},
1357+
"png": {
1358+
"outputScale": 1,
1359+
"minVisiblePixels": 26360,
1360+
"minDistinctColors": 927,
1361+
"maxEdgeInkPixels": 0
1362+
}
1363+
},
1364+
{
1365+
"name": "markup-timeline-release-plan",
1366+
"width": 980,
1367+
"height": 560,
1368+
"svg": {
1369+
"minVisualNodes": 38,
1370+
"maxClippedTextNodes": 0,
1371+
"maxNearEdgeTextNodes": 0
1372+
},
1373+
"png": {
1374+
"outputScale": 1,
1375+
"minVisiblePixels": 257471,
1376+
"minDistinctColors": 934,
1377+
"maxEdgeInkPixels": 0
1378+
}
1379+
},
1380+
{
1381+
"name": "markup-topology-service-map",
1382+
"width": 1144,
1383+
"height": 689,
1384+
"svg": {
1385+
"minVisualNodes": 42,
1386+
"maxClippedTextNodes": 0,
1387+
"maxNearEdgeTextNodes": 0
1388+
},
1389+
"png": {
1390+
"outputScale": 1,
1391+
"minVisiblePixels": 394108,
1392+
"minDistinctColors": 977,
1393+
"maxEdgeInkPixels": 0
1394+
}
1395+
},
13001396
{
13011397
"name": "monthly-posture-dark",
13021398
"width": 760,
@@ -1910,7 +2006,7 @@
19102006
"width": 1280,
19112007
"height": 814,
19122008
"svg": {
1913-
"minVisualNodes": 150,
2009+
"minVisualNodes": 151,
19142010
"maxClippedTextNodes": 0,
19152011
"maxNearEdgeTextNodes": 0
19162012
},

ChartForgeX.Markup.Cli/ChartForgeX.Markup.Cli.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<ItemGroup>
2424
<ProjectReference Include="..\ChartForgeX\ChartForgeX.csproj" />
2525
<ProjectReference Include="..\ChartForgeX.Markup\ChartForgeX.Markup.csproj" />
26+
<ProjectReference Include="..\ChartForgeX.Markup.Mermaid\ChartForgeX.Markup.Mermaid.csproj" />
2627
</ItemGroup>
2728
</Project>

0 commit comments

Comments
 (0)