TAdvStringGrid

Example 31 : TAdvStringGrid linked to TChart via TChartLink

vcl grid chartlink

Often, data from a grid must be reflected in a chart. Although this can be done by writing code to apply the grid's data in the chart series, the TChartLink component introduces a code-less approach for direct chart updates driven by grid data. A TChartLink component is the gateway from the grid's data to a single chart series. Therefore, a TChartLink component has 2 properties : Grid and Series. Assign TAdvStringGrid to Grid and add a series to a TChart and assign this series to the Series property. The series and chart can be fully formatted with the TChart component. The next step is to identify which data from the grid should be shown in the chart. This is done with the GridLegends and GridData properties. Following types of links can be used:

dtNone : no cells are reflected in the chart. This is especially useful when the legends do not need to be reflected in the chart.
dtCellRange : selected range of cells is reflected in the chart. Which cells are set with the Left,Top,Right,Bottom properties.
dtFullColumn : the complete column, including fixed rows is reflected in the chart. Which column is set with the Column property.
dtNormalColumn : all non-fixed cells from a column are reflected in the chart. Which column is set with the Column property.
dtFullRow : the complete row, including fixed rows is reflected in the chart. Which row is set with the Row property.
dtNormalRow : all non-fixed cells from a row are reflected in the chart. Which row is set with the Row property.

As soon as the Active property is true, the data in the grid is reflected in the chart. The chart data is also automatically updated during editing of the grid.

If no direct update of the chart is required during editing, the active property can be set false again. At the time the chart needs to be refreshed, it is sufficient to set it active.

As explained, there is no code involved. All this can be setup at design time in pure RAD style.

Delphi project & source files for downloading included in the main demos distribution for Delphi.