1

I have a dynamic multi-dimensional array containing the coordinate data for TLine Series graphs. I would like to simply associate the inner arrays with the ValueLists for the X axis and Y axes without either copying the elements to individual single dimension arrays first, or using the AddXY method.

The multidimensional array is declared, length set and filled with data as in the code snippets below:

var
  // The number of records fetched from the Database table.
  recordCount : Integer;

  // Arrays to hold time series data from battery records for TChart.
  // The first dimension is for each series (index 0 is for the X-axis,
  // i.e.timestamps).  The second dimension is the value for that axis
  // at each point.
  arrBatteryData: Array of Array of Double;
  // ...
  // ...  
  SetLength( arrBatteryData, 2, recordCount );

  // ...
  // ...

  arrBatteryData[0, AIndex] := AtimeStamp;
  arrBatteryData[1, AIndex] := Double(ABatteryJS.Field['voltage'].Value );
  arrBatteryData[2, AIndex] := Double(ABatteryJS.Field['temperature'].Value   

The LineSeries are defined as follows:

var
  serBatteryVoltage     : TLineSeries;
  serBatteryTemperature : TLineSeries;

// ...
// ...

  // Delete all Series objects then create new ones and assign to the Chart.
  chtBatteryData.RemoveAllSeries;  
  serBatteryVoltage := TLineSeries.Create( Self );
  serBatteryVoltage.Title := 'Voltage';
  serBatteryVoltage.ParentChart := chtBatteryData;

  serBatteryTemperature := TLineSeries.Create( Self );
  serBatteryTemperature.ParentChart := chtBatteryData;
  serBatteryTemperature.Title := 'Temperature';

How can I assign the relevant 2nd dimension arrays to each ValueList? I'd hope that I can do this rather than having to declare and fill single-dimension arrays for each ValueList, or having to use the AddXY method for each point on each series.

Is this achievable in Teechart?

eccles
  • 21
  • 2

0 Answers0