CandlestickChart 组件 — sgcHTML | eSeGeCe

CandlestickChart

TsgcHTMLComponent_CandlestickChart — 渲染带有影线、涨跌配色和可选成交量条的 SVG OHLC 蜡烛图,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_CandlestickChart

使用 AddPoint 为每根 K 线添加一个 OHLC 数据点(或绑定数据集),然后读取 HTML 属性。

组件类

TsgcHTMLComponent_CandlestickChart

渲染为

内联 SVG OHLC 图表 + 可选成交量条(无需图表库)

语言

Delphi, C++ Builder, .NET

添加 OHLC 数据点,渲染它

为每根 K 线调用 AddPoint(aLabel, aOpen, aHigh, aLow, aClose, aVolume)(或绑定数据集),然后读取 HTML

uses
  sgcHTML_Component_CandlestickChart;

var
  oChart: TsgcHTMLComponent_CandlestickChart;
begin
  oChart := TsgcHTMLComponent_CandlestickChart.Create(nil);
  try
    oChart.Width := 800;
    oChart.Height := 400;
    oChart.ShowVolume := True;

    oChart.AddPoint('Mon', 101.2, 104.8, 100.1, 103.5, 125000);
    oChart.AddPoint('Tue', 103.5, 106.0, 102.8, 105.1, 98000);
    oChart.AddPoint('Wed', 105.1, 105.4, 101.0, 101.9, 154000);

    WebModule.Response := oChart.HTML;   // SVG candles + wicks + volume strip
  finally
    oChart.Free;
  end;
end;

// Or bind it straight to a dataset:
oChart.LoadFromDataSet(qryOHLC, 'TradeDate', 'OpenPrice', 'HighPrice',
  'LowPrice', 'ClosePrice', 'Volume');
// includes: sgcHTML_Component_CandlestickChart.hpp

TsgcHTMLComponent_CandlestickChart *oChart = new TsgcHTMLComponent_CandlestickChart(NULL);
try
{
  oChart->Width = 800;
  oChart->Height = 400;
  oChart->ShowVolume = true;

  oChart->AddPoint("Mon", 101.2, 104.8, 100.1, 103.5, 125000);
  oChart->AddPoint("Tue", 103.5, 106.0, 102.8, 105.1, 98000);
  oChart->AddPoint("Wed", 105.1, 105.4, 101.0, 101.9, 154000);

  String html = oChart->HTML;   // SVG candles + wicks + volume strip
}
__finally
{
  delete oChart;
}
using esegece.sgcWebSockets;

var chart = new TsgcHTMLComponent_CandlestickChart();
chart.Width = 800;
chart.Height = 400;
chart.ShowVolume = true;

chart.AddPoint("Mon", 101.2, 104.8, 100.1, 103.5, 125000);
chart.AddPoint("Tue", 103.5, 106.0, 102.8, 105.1, 98000);
chart.AddPoint("Wed", 105.1, 105.4, 101.0, 101.9, 154000);

string html = chart.HTML;   // SVG candles + wicks + volume strip

关键属性与方法

您最常使用的成员。

数据点

AddPoint(aLabel, aOpen, aHigh, aLow, aClose, aVolume) 追加一根 OHLC K 线,并返回 TsgcHTMLCandlestickPoint

数据集绑定

LoadFromDataSet(aDataSet, aDateField, aOpenField, aHighField, aLowField, aCloseField, aVolumeField) 直接从查询构建数据系列。

K 线颜色

UpColor/DownColor 根据涨跌方向为实体上色;WickColor 用于覆盖最高最低影线的颜色。

成交量

ShowVolume 在 K 线下方添加一个成交量条,按最高柱进行缩放。

坐标轴与网格

ShowAxis/ShowGrid/GridLines/FontSize/Decimals 控制价格坐标轴。

布局与比例

Width/Height/CandleWidth 设置图表尺寸;MinValue/MaxValueAutoMin/AutoMax 配合可固定价格范围。

继续探索

在线帮助此组件的完整 API 参考和使用指南。
所有 sgcHTML 组件浏览 80 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。

准备好开始了吗?

下载免费试用版,开始在 Delphi、C++ Builder 和 .NET 中构建 Web 界面。