How to Quickly Add Thousands of Points to a T chart
The trick is to pre-allocate the memory for the points in the chart series.
Step-by-Step Guide
-
Step 1: The trick is to pre-allocate the memory for the points in the chart series.
There is no obvious function in TSeries that does this, but the FillSampleValues function serves the same purpose by filling the series with a known number of points. // load the data into a memory stream ms->LoadFromFile("data"); // compute number of points numpts = ms->Seek (0, soFromEnd)/sizeof(cd); // pre-allocate space Series1->FillSampleValues(numpts); // load the data into the chart ms->Position = ms->Seek(0, soFromBeginning); for (unsigned i=0; i < numpts; i++) { ms->Read(&cd, numbytes); Series1->XValues->Value= cd.x; Series1->YValues->Value= cd.y; };
Detailed Guide
There is no obvious function in TSeries that does this, but the FillSampleValues function serves the same purpose by filling the series with a known number of points. // load the data into a memory stream ms->LoadFromFile("data"); // compute number of points numpts = ms->Seek (0, soFromEnd)/sizeof(cd); // pre-allocate space Series1->FillSampleValues(numpts); // load the data into the chart ms->Position = ms->Seek(0, soFromBeginning); for (unsigned i=0; i < numpts; i++) { ms->Read(&cd, numbytes); Series1->XValues->Value= cd.x; Series1->YValues->Value= cd.y; };
About the Author
Albert Howard
Albert Howard specializes in digital media and internet and has been creating helpful content for over 17 years. Albert is committed to helping readers learn new skills and improve their lives.
Rate This Guide
How helpful was this guide? Click to rate: