Heatmap 组件 — sgcHTML | eSeGeCe

Heatmap

TsgcHTMLComponent_Heatmap — 从单元格值或绑定数据集渲染颜色渐变 SVG 热力图网格,带有图例和行/列标签,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_Heatmap

设置行和列标签,使用 SetCell 填充单元格(或绑定数据集),然后读取 HTML 属性。

组件类

TsgcHTMLComponent_Heatmap

渲染为

内联 SVG 热力图网格 + 可选图例(无需图表库)

语言

Delphi, C++ Builder, .NET

标注网格、填充单元格、渲染它

填充 RowLabelsColumnLabels,为每个数据点调用 SetCell(aRow, aCol, aValue)(或绑定数据集),然后读取 HTML

uses
  sgcHTML_Component_Heatmap;

var
  oHeatmap: TsgcHTMLComponent_Heatmap;
begin
  oHeatmap := TsgcHTMLComponent_Heatmap.Create(nil);
  try
    oHeatmap.RowLabels.CommaText := 'Mon,Tue,Wed,Thu,Fri';
    oHeatmap.ColumnLabels.CommaText := '9h,12h,15h,18h';
    oHeatmap.ShowLegend := True;
    oHeatmap.ShowValues := True;

    oHeatmap.SetCell(0, 0, 12);
    oHeatmap.SetCell(0, 1, 48);
    oHeatmap.SetCell(1, 2, 76);
    oHeatmap.SetCell(4, 3, 92);

    WebModule.Response := oHeatmap.HTML;   // SVG grid, min->max colour scale
  finally
    oHeatmap.Free;
  end;
end;

// Or bind it straight to a dataset:
oHeatmap.LoadFromDataSet(qryTraffic, 'DayName', 'HourSlot', 'Visits');
// includes: sgcHTML_Component_Heatmap.hpp

TsgcHTMLComponent_Heatmap *oHeatmap = new TsgcHTMLComponent_Heatmap(NULL);
try
{
  oHeatmap->RowLabels->CommaText = "Mon,Tue,Wed,Thu,Fri";
  oHeatmap->ColumnLabels->CommaText = "9h,12h,15h,18h";
  oHeatmap->ShowLegend = true;
  oHeatmap->ShowValues = true;

  oHeatmap->SetCell(0, 0, 12);
  oHeatmap->SetCell(0, 1, 48);
  oHeatmap->SetCell(1, 2, 76);
  oHeatmap->SetCell(4, 3, 92);

  String html = oHeatmap->HTML;   // SVG grid, min->max colour scale
}
__finally
{
  delete oHeatmap;
}
using esegece.sgcWebSockets;

var heatmap = new TsgcHTMLComponent_Heatmap();
heatmap.RowLabels.CommaText = "Mon,Tue,Wed,Thu,Fri";
heatmap.ColumnLabels.CommaText = "9h,12h,15h,18h";
heatmap.ShowLegend = true;
heatmap.ShowValues = true;

heatmap.SetCell(0, 0, 12);
heatmap.SetCell(0, 1, 48);
heatmap.SetCell(1, 2, 76);
heatmap.SetCell(4, 3, 92);

string html = heatmap.HTML;   // SVG grid, min->max colour scale

关键属性与方法

您最常使用的成员。

单元格

SetCell(aRow, aCol, aValue) 写入一个值;FindCell 查找一个值,ClearData 清空 Cells 集合。

标签

RowLabelsColumnLabelsTStringList,用于命名网格的每一行和每一列。

颜色比例尺

MinColor/MaxColor/EmptyColor 按单元格混合;AutoMin/AutoMax 固定 MinValue/MaxValue,而不是根据数据自动缩放。

数据集绑定

LoadFromDataSet(aDataSet, aRowField, aColField, aValueField) 直接从查询构建网格。

单元格显示

CellSize/CellGap/Rounded 决定单元格的形状;ShowValues/Decimals/FontSize 控制显示的数字。

图例与标签

ShowLegend 绘制从最小值到最大值的渐变条;ShowRowLabels/ShowColumnLabels 切换坐标轴文本的显示。

继续探索

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

准备好开始了吗?

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