2using System.Collections.Generic;
4using System.Threading.Tasks;
17 private readonly LinkedList<ISource> sources =
new LinkedList<ISource>();
18 private int count = 0;
36 public string Title => this.title;
42 public override Task
FromXml(XmlElement Definition)
48 return base.FromXml(Definition);
57 this.sources.AddLast(
Source);
67 Output.WriteLine(
"{");
68 Output.WriteLine(
"GraphWidth:=1000;");
69 Output.WriteLine(
"GraphHeight:=400;");
71 Output.WriteLine(
"}");
76 List<string> Labels =
new List<string>();
91 public static void ExportLegend(StreamWriter Output,
string[] Labels, params SKColor[] Palette)
95 if (Palette is
null || Palette.Length < Labels.Length)
98 Output.WriteLine(
"```layout: Legend");
99 Output.WriteLine(
"<Layout2D xmlns=\"http://waher.se/Schema/Layout2D.xsd\"");
100 Output.WriteLine(
" background=\"WhiteBackground\" pen=\"BlackPen\"");
101 Output.WriteLine(
" font=\"Text\" textColor=\"Black\">");
102 Output.WriteLine(
" <SolidPen id=\"BlackPen\" color=\"Black\" width=\"1px\"/>");
103 Output.WriteLine(
" <SolidBackground id=\"WhiteBackground\" color=\"WhiteSmoke\"/>");
105 foreach (
string Label
in Labels)
107 SKColor Color = Palette[i++];
109 Output.Write(
" <SolidBackground id=\"");
111 Output.Write(
"Bg\" color=\"");
113 Output.WriteLine(
"\"/>");
116 Output.WriteLine(
" <Font id=\"Text\" name=\"Arial\" size=\"8pt\" color=\"Black\"/>");
117 Output.WriteLine(
" <Grid columns=\"2\">");
119 foreach (
string Label
in Labels)
121 Output.WriteLine(
" <Cell>");
122 Output.WriteLine(
" <Margins left=\"1mm\" top=\"1mm\" bottom=\"1mm\" right=\"1mm\">");
123 Output.Write(
" <RoundedRectangle radiusX=\"1mm\" radiusY=\"1mm\" width=\"5mm\" height=\"5mm\" fill=\"");
126 Output.WriteLine(
"\"/>");
127 Output.WriteLine(
" </Margins>");
128 Output.WriteLine(
" </Cell>");
129 Output.WriteLine(
" <Cell>");
130 Output.WriteLine(
" <Margins left=\"0.5em\" right=\"0.5em\">");
131 Output.Write(
" <Label text=\"");
133 Output.WriteLine(
"\" x=\"0%\" y=\"50%\" halign=\"Left\" valign=\"Center\" font=\"Text\"/>");
134 Output.WriteLine(
" </Margins>");
135 Output.WriteLine(
" </Cell>");
138 Output.WriteLine(
" </Grid>");
139 Output.WriteLine(
"</Layout2D>");
140 Output.WriteLine(
"```");
158 Output.WriteLine(
"G:=Sum([(");
168 Output.WriteLine(
"), (");
177 Output.WriteLine(
")]);");
178 Output.Write(
"G.LabelX:=\"Time × ");
180 Output.WriteLine(
"\";");
181 Output.Write(
"G.Title:=\"");
182 Output.Write(this.title.Replace(
"\"",
"\\\""));
183 Output.WriteLine(
"\";");
184 Output.WriteLine(
"G");
Root node of a simulation model
static SKColor[] CreatePalette(int N)
Creates a palette for graphs.
static string ToString(SKColor Color)
Gets the string representation of a color.
string TimeUnitStr
Time unit string
Abstract base class for combined graphs
string Title
Title of graph.
virtual void Register(ISource Source)
Registers a source.
override bool ExportGraphScript(StreamWriter Output, string CustomColor, bool Span)
Exports the graph to a markdown output.
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
CombinedGraph(ISimulationNode Parent, Model Model)
Abstract base class for combined graphs
override void ExportGraph(StreamWriter Output)
Exports the graph to a markdown output.
static void ExportLegend(StreamWriter Output, string[] Labels, params SKColor[] Palette)
Exports a legend.
abstract IGraph GetGraph(string Reference)
Gets a graph from its reference.
Abstract base class for graph nodes
abstract bool ExportGraphScript(StreamWriter Output, string CustomColor, bool Span)
Exports the graph to a markdown output.
string Reference
Reference
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Static class managing the application event log. Applications and services log events on this static ...
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Interface for graph nodes
Interface for nodes holding a source node