Scenario:
I'm adding values to the TeeChart dynamically (including custom axes, series, and series values).
I get the desired results with the exception of the chart not formatting nicely (like it does when it's set up via the wizard).
I'm sure it's just a matter of refreshing the template or something like that, I just don't know how!
Here are my examples:
This is how the original graph looks like This is how my new graph looks like My main concern at this point is the following:
I need my new graph to only show bottom axis label for where there are records (just like the first one)
I need the graph to show xy axis labels where there are records (just like the first one)
I need the left margin to adjust automatically to show the full reading labels and axis titles (just like the first one)
Please advise, I need this ASAP since we're supposed to release soon!
FYI: here is some of the sample code, just snippets not the entire function (I don't think you really need it but just so you know how I'm doing this):
fraPCTGraphByAnalysis.chtGraph.CustomAxes.Clear;
fraPCTGraphByAnalysis.chtGraph.RemoveAllSeries;
Adding the custom axes:
Code: Select all
sgSeriesGroup := fraPCTGraphByAnalysis.chtGraph.SeriesList.AddGroup(slProductTypes[i]);
caAxis := fraPCTGraphByAnalysis.chtGraph.CustomAxes.Add as TChartAxis;
caAxis.Title.Angle := 90;
caAxis.Title.Caption := slProductTypes[i];
caAxis.StartPosition := iAxesStart;
caAxis.EndPosition := iAxesStart + iAxesSize;
caAxis.AxisValuesFormat := '#0.000';
Code: Select all
for i2 := 0 to slChemicalComponents.Count - 1 do
begin
csSeries := TLineSeries.Create(self);
csSeries.Pointer.Visible := true;
csSeries.Pointer.Size := 2;
csSeries.Title := slChemicalComponents[i2];
csSeries.CustomVertAxis := caAxis;
csSeries.XValues.DateTime := true;
sgSeriesGroup.Add(csSeries);
fraPCTGraphByAnalysis.chtGraph.AddSeries(csSeries);
end;
Code: Select all
for i2 := 0 to Length(aReadingRecord) - 1 do
//consider records that only belong to this Product group (for loop "i")
if aReadingRecord[i2].sProduct = caAxis.Title.Caption then
begin
//get the series in the current Product group
for i3 := 0 to sgSeriesGroup.Series.Count - 1 do
if aReadingRecord[i2].sSeries = sgSeriesGroup.Series[i3].Title then
sgSeriesGroup.Series[i3].AddXY(aReadingRecord[i2].dTestDate,aReadingRecord[i2].fReading);
end;
end;