Preview


1000 × 820 pixels
Create this example
Create a console project, add the ChartForgeX package, and replace Program.cs with this source. Run it to write SVG, PNG and HTML with the default system fonts.
For the same typography as the gallery, download the gallery-font recipe and copy the gallery’s fonts directory beside your program.
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;
var mode = ThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = SequenceMessagePresentationRecipe.Create("wide", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(1000, 820)), theme, mode,
new VisualFrame("Message presentation", "Aligned captions and measured occurrence numbers", showLegend: false, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Sequence).ToHtmlPage());
#endregion
/// <summary>Creates a native sequence with aligned multiline captions and independently measured number badges.</summary>
public static class SequenceMessagePresentationRecipe {
/// <summary>Creates compact or wide native message presentation through the shared preparation owner.</summary>
public static SequenceArtifact Create(string variant="wide",ThemeMode mode=ThemeMode.Light) {
if(variant is not ("compact" or "wide"))throw new ArgumentOutOfRangeException(nameof(variant));
var model=SequenceArtifact.Create("sequence-message-presentation").Width(variant=="compact"?390:1000).Height(820)
.Title("Message presentation").Subtitle("Measured number badges and independent message/note alignment")
.AddParticipant("A","Review").AddParticipant("B","Archive").AddMessage("A","B","Save\nFact")
.AddMessage("B","A","Ready\nNext",SequenceArtifactMessageLineStyle.Dashed,SequenceArtifactMessageKind.Return).AddMessage("B","B","Check\nSelf")
.AddNote(SequenceArtifactNotePlacement.Over,new[]{"A","B"},"Review\nNote");
model.Notes[0].StepIndex=1;model.Metadata["mermaid.autonumber"]="true";model.Metadata["mermaid.autonumber.start"]="1000";
model.Layout=new SequenceLayoutPolicy(participantMinimumWidth:64,participantMinimumHeight:60,participantSpacing:8,wrapPadding:8,
messageAlignment:TextAlignment.Right,noteAlignment:TextAlignment.Center,numberPresentation:SequenceNumberPresentation.Badge);
model.Typography=new SequenceTypography(participant:new TextStyleOverride{FontSize=14},message:new TextStyleOverride{FontSize=12},note:new TextStyleOverride{FontSize=12});
model.Paint.MessageLine=ChartColor.FromHex("#3b5ccc");model.Paint.NumberText=ChartColor.White;model.Theme=VisualTheme.Graphite();model.ThemeMode=mode;return model;
}
}
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;
var mode = ThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = SequenceMessagePresentationRecipe.Create("wide", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(1000, 820)), theme, mode,
new VisualFrame("Message presentation", "Aligned captions and measured occurrence numbers", showLegend: false, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Sequence).ToHtmlPage());
#endregion
/// <summary>Creates a native sequence with aligned multiline captions and independently measured number badges.</summary>
public static class SequenceMessagePresentationRecipe {
/// <summary>Creates compact or wide native message presentation through the shared preparation owner.</summary>
public static SequenceArtifact Create(string variant="wide",ThemeMode mode=ThemeMode.Light) {
if(variant is not ("compact" or "wide"))throw new ArgumentOutOfRangeException(nameof(variant));
var model=SequenceArtifact.Create("sequence-message-presentation").Width(variant=="compact"?390:1000).Height(820)
.Title("Message presentation").Subtitle("Measured number badges and independent message/note alignment")
.AddParticipant("A","Review").AddParticipant("B","Archive").AddMessage("A","B","Save\nFact")
.AddMessage("B","A","Ready\nNext",SequenceArtifactMessageLineStyle.Dashed,SequenceArtifactMessageKind.Return).AddMessage("B","B","Check\nSelf")
.AddNote(SequenceArtifactNotePlacement.Over,new[]{"A","B"},"Review\nNote");
model.Notes[0].StepIndex=1;model.Metadata["mermaid.autonumber"]="true";model.Metadata["mermaid.autonumber.start"]="1000";
model.Layout=new SequenceLayoutPolicy(participantMinimumWidth:64,participantMinimumHeight:60,participantSpacing:8,wrapPadding:8,
messageAlignment:TextAlignment.Right,noteAlignment:TextAlignment.Center,numberPresentation:SequenceNumberPresentation.Badge);
model.Typography=new SequenceTypography(participant:new TextStyleOverride{FontSize=14},message:new TextStyleOverride{FontSize=12},note:new TextStyleOverride{FontSize=12});
model.Paint.MessageLine=ChartColor.FromHex("#3b5ccc");model.Paint.NumberText=ChartColor.White;model.Theme=VisualTheme.Graphite();model.ThemeMode=mode;return model;
}
}