The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Unit: SDL_rchart
Class: TRChart
Declaration: property AnnoContainer[idx: longint]: TrcChartItem;

The annotation elements such as lines, marks, text labels, etc. are stored in a dynamic array which is accessible via the array property AnnoContainer. The index idx of the array may take values between 0 (the first element) and NumAnnos-1 (the last item).

Example: You can edit annotations by modifying the corresponding container elements. The following code snippet shows a situation which is typically encountered when the user clicks the chart (here: CP1). Assuming that you know the real-world coordinates of the mouse click (MouseX and MouseY) you can detect the closest annotation element and change for example its color:
  idx   : integer;
  dist  : double;
  item  : TRcChartItem;

begin                              // retrieve the closest annotation item
idx := CP1.FindNearestAnnoElem (MouseX, MouseY, tkNotMoveTo, 255, true, dist);
if idx >= 0 then
  item := CP1.AnnoContainer[idx];  // obtain the annotation item
  if item.Color = clred            // change its colors
    then item.Color := clBlue
    else item.Color := clRed;
  if item.FillColor = clMoneyGreen
    then item.FillColor := clYellow
    else item.FillColor := clMoneyGreen;
  CP1.AnnoContainer[idx] := item;  // write the item back to the container
  CP1.DrawPlot;                    // trigger the repainting of the chart

Last Update: 2023-Dec-13