Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS VCL Chart
Adding single, multi points

Depending on the chosen chart type different methods are available to add series data point values to a series. This is done via a number of overload functions of AddSinglePoint and AddMultiPoint. For some chart types, a single value per series data point is sufficient. Other chart types such as a band chart or OHLC chart require 2 or 4 values per series data point. Additional settings per data point might be necessary such as a specific chart X-axis value for a data point or a color of a data point for a histogram.

The easiest way to add points is with the method AddSinglePoint or AddMultiPoint. Alternatively the methods SetSinglePoint or SetMultiPoint can also be used to change values of some data points in a serie. Note though that when no data points are added in the series, it is required to set the number of points first with the method SetArraySize() before using SetSinglePoint or SetMultiPoint. In this example we use the Add Methods:

Example: Adding some random points for different chart types.
procedure TForm1.AddRandomSinglePoints; 
var 
  i: integer; 
begin 
  with AdvChartView.Panes[0].Series[0] do 
  begin 
    //Applies to ctLine, ctDigitalLine, ctBar, ctArea, ctHistogram, ctLineBar, 
    //ctLineHistogram, ctStackedBar, ctStackedArea, ctStackedPercBar, 
    //ctStackedPercArea, ctMarkers 
    for i := 0 to 10 do 
      AddSinglePoint(Random(50)); 
    //Applies to ctArrow, ctError, ctScaledArrow, ctBubble, 
    //ctScaledBubble (Random points with X an Y offset) 
    for i := 0 to 10 do 
      AddPoints(Random(50), XOffset, YOffset); 
  end; 
end; 

procedure TForm1.AddRandomMultiPoints; 
var 
  i: integer; 
begin 
  with AdvChartView.Panes[0].Series[0] do 
  begin 
     //Randomly add some points ranging from 0 to 10 
    //Applies to ctCandleStick, ctOHLC, ctLineCandleStick 
    for i := 0 to 10 do 
      AddMultiPoints(Random(50), Random(50), Random(50), Random(50)); 
  end; 
end;
Note: Always set the RangeFrom and the RangeTo to the range of points you have added to the serie that you want to visualize..

Example: Adding points for every month of the year.

You can quickly add custom text to the X-axis by using one of the overloaded AddSinglePoint methods.
for I := 0 to 11 do 
begin 
  AdvChartView1.Panes[0].Series[0].AddSinglePoint(Random(100) + 10, 
  ShortMonthNames[I + 1]); 
end;