Diagram
TsgcHTMLComponent_Diagram — render a node-and-arrow flow diagram as inline SVG, placing nodes at fixed coordinates and connecting them with labelled arrows, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Diagram — render a node-and-arrow flow diagram as inline SVG, placing nodes at fixed coordinates and connecting them with labelled arrows, in Delphi, C++ Builder and .NET.
A flowchart component that emits a self-contained inline <svg>. Add nodes at X/Y coordinates, connect them with arrows, then read the HTML property.
TsgcHTMLComponent_Diagram
Inline <svg> nodes and arrows
Delphi, C++ Builder, .NET
Call AddNode for each box (with its position, colour and shape), wire them with Connect, then read HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Diagram;
var
oDiagram: TsgcHTMLComponent_Diagram;
begin
oDiagram := TsgcHTMLComponent_Diagram.Create(nil);
try
oDiagram.DiagramWidth := 600;
oDiagram.DiagramHeight := 300;
oDiagram.AddNode('start', 'Start', 240, 20, hcSuccess, nsCircle);
oDiagram.AddNode('work', 'Process', 240, 120, hcPrimary, nsRoundedRect);
oDiagram.AddNode('done', 'Finish', 240, 220, hcDanger, nsDiamond);
oDiagram.Connect('start', 'work', 'begin');
oDiagram.Connect('work', 'done', 'commit');
WebModule.Response := oDiagram.HTML; // inline <svg> flow diagram
finally
oDiagram.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Diagram.hpp
TsgcHTMLComponent_Diagram *oDiagram = new TsgcHTMLComponent_Diagram(NULL);
try
{
oDiagram->DiagramWidth = 600;
oDiagram->DiagramHeight = 300;
oDiagram->AddNode("start", "Start", 240, 20, hcSuccess, nsCircle);
oDiagram->AddNode("work", "Process", 240, 120, hcPrimary, nsRoundedRect);
oDiagram->AddNode("done", "Finish", 240, 220, hcDanger, nsDiamond);
oDiagram->Connect("start", "work", "begin");
oDiagram->Connect("work", "done", "commit");
String html = oDiagram->HTML; // inline <svg> flow diagram
}
__finally
{
delete oDiagram;
}
using esegece.sgcWebSockets;
var diagram = new TsgcHTMLComponent_Diagram();
diagram.DiagramWidth = 600;
diagram.DiagramHeight = 300;
diagram.AddNode("start", "Start", 240, 20, TsgcHTMLColor.hcSuccess, TsgcHTMLDiagramNodeShape.nsCircle);
diagram.AddNode("work", "Process", 240, 120, TsgcHTMLColor.hcPrimary, TsgcHTMLDiagramNodeShape.nsRoundedRect);
diagram.AddNode("done", "Finish", 240, 220, TsgcHTMLColor.hcDanger, TsgcHTMLDiagramNodeShape.nsDiamond);
diagram.Connect("start", "work", "begin");
diagram.Connect("work", "done", "commit");
string html = diagram.HTML; // inline <svg> flow diagram
The members you reach for most often.
Nodes (TsgcHTMLDiagramNodes) holds the boxes; each TsgcHTMLDiagramNode exposes NodeID, Text, X, Y, Width, Height, Color and Shape.
AddNode(aID, aText, aX, aY, aColor, aShape) appends a node and returns it; aColor is a TsgcHTMLColor, aShape a TsgcHTMLDiagramNodeShape.
TsgcHTMLDiagramNodeShape offers nsRectangle, nsRoundedRect, nsCircle and nsDiamond.
Connections (TsgcHTMLDiagramConnections) holds the arrows; each TsgcHTMLDiagramConnection has FromNode, ToNode, Label_ and Color.
Connect(aFromID, aToID, aLabel_) draws a labelled arrow between two nodes referenced by their NodeID.
DiagramWidth, DiagramHeight and DiagramID size and identify the SVG; HTML returns the inline <svg> with arrows drawn behind the nodes.