Sparkline
TsgcHTMLComponent_Sparkline — render a compact inline SVG line, bar or area sparkline from a value series or a bound dataset, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Sparkline — render a compact inline SVG line, bar or area sparkline from a value series or a bound dataset, in Delphi, C++ Builder and .NET.
Push values with AddValue or SetData (or bind a dataset), pick a ChartType, then read the HTML property — or call the Build one-liner.
TsgcHTMLComponent_Sparkline
Inline SVG sparkline (span, no chart library)
Delphi, C++ Builder, .NET
Call AddValue or SetData for the series (or LoadFromDataSet), set ChartType, then read HTML.
uses
sgcHTML_Component_Sparkline;
var
oSpark: TsgcHTMLComponent_Sparkline;
sHTML: string;
begin
oSpark := TsgcHTMLComponent_Sparkline.Create(nil);
try
oSpark.ChartType := slArea;
oSpark.Width := 160;
oSpark.Height := 32;
oSpark.ShowLastPoint := True;
oSpark.SetData([14, 18, 12, 22, 30, 26, 34]);
WebModule.Response := oSpark.HTML; // inline SVG, no chart library
finally
oSpark.Free;
end;
end;
// Or bind it straight to a dataset:
oSpark.LoadFromDataSet(qryRevenue, 'Amount');
// One-liner for inline use inside a bigger page:
sHTML := TsgcHTMLComponent_Sparkline.Build([5, 9, 4, 12, 7], slBar);
// includes: sgcHTML_Component_Sparkline.hpp
TsgcHTMLComponent_Sparkline *oSpark = new TsgcHTMLComponent_Sparkline(NULL);
try
{
oSpark->ChartType = slArea;
oSpark->Width = 160;
oSpark->Height = 32;
oSpark->ShowLastPoint = true;
double vValues[] = {14, 18, 12, 22, 30, 26, 34};
for (int i = 0; i < 7; i++)
oSpark->AddValue(vValues[i]);
String html = oSpark->HTML; // inline SVG, no chart library
}
__finally
{
delete oSpark;
}
using esegece.sgcWebSockets;
var spark = new TsgcHTMLComponent_Sparkline();
spark.ChartType = TsgcHTMLSparklineType.slArea;
spark.Width = 160;
spark.Height = 32;
spark.ShowLastPoint = true;
foreach (var v in new double[] { 14, 18, 12, 22, 30, 26, 34 })
spark.AddValue(v);
string html = spark.HTML; // inline SVG, no chart library
The members you reach for most often.
AddValue(aValue) appends one point; SetData(array of Double) replaces the whole series; ClearData empties it.
LoadFromDataSet(aDataSet, aValueField) reads one value per row, in dataset order.
The class function Build(aValues, aChartType, aLineColor) returns ready HTML without managing an instance.
ChartType (slLine, slBar, slArea) picks how the series is drawn.
LineColor/FillColor/LineWidth control the stroke and fill; Width/Height size the SVG.
ShowLastPoint/ShowMinMax highlight key points; Min/Max with AutoMin/AutoMax pin the Y range.
| Online HelpFull API reference and usage guide for this component. | Open | |
| All sgcHTML ComponentsBrowse the full feature matrix of 80+ components. | Open | |
| Download Free TrialThe 30-day trial ships the 60.HTML demo projects. | Open | |
| PricingSingle, Team and Site licenses with full source code. | Open |