Sparkline Component — sgcHTML | eSeGeCe

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

Push values with AddValue or SetData (or bind a dataset), pick a ChartType, then read the HTML property — or call the Build one-liner.

Component class

TsgcHTMLComponent_Sparkline

Renders

Inline SVG sparkline (span, no chart library)

Languages

Delphi, C++ Builder, .NET

Feed values, pick a chart type, render it

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

Key properties & methods

The members you reach for most often.

Adding data

AddValue(aValue) appends one point; SetData(array of Double) replaces the whole series; ClearData empties it.

Dataset binding

LoadFromDataSet(aDataSet, aValueField) reads one value per row, in dataset order.

One-liner

The class function Build(aValues, aChartType, aLineColor) returns ready HTML without managing an instance.

Chart type

ChartType (slLine, slBar, slArea) picks how the series is drawn.

Styling

LineColor/FillColor/LineWidth control the stroke and fill; Width/Height size the SVG.

Markers & scale

ShowLastPoint/ShowMinMax highlight key points; Min/Max with AutoMin/AutoMax pin the Y range.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.