Mawg
Mawg

Reputation: 40145

TCHart - get number of points I have added to a series

I am using Chart1.Series[0].AddXY() to add points to a chart.

Sine I will add each new point one X-axis pixel after the last, I thought I could use something like Chart1.Series[0].AddXY(Chart1.Series[0].NumSampleValues, codValue, '', clRed ); but, for some reason, Chart1.Series[0].NumSampleValues always evaluates to 26.

I guess I am using the wrong property. Which should I be using?

Upvotes: 0

Views: 2097

Answers (2)

Bharat
Bharat

Reputation: 6866

I think you should not use NumSampleValues

If you want to add at the last (provided that you are incrementing X-axis by 1) you can use Series1.XValues.Count;

Upvotes: 5

jpfollenius
jpfollenius

Reputation: 16620

What about TChartSeries.Count?

TChartSeries.Count TChartSeries

function Count: Integer;

Unit TeEngine

Description This function returns the number of points in the Series.

And just for completeness: This is what NumSampleValues does:

Each Series draws random values at design mode unless you connect the Series component to other Series component or to a DataSet (Table,SQL,TClientDataset) component.

This virtual function returns the predefined number of random values each Series draws.

Upvotes: 2

Related Questions