Page 1 of 1
TBarSeries
Posted: Fri Apr 23, 2004 3:07 pm
by 5893652
TDBTeeChart/ TBarSeries, under the condition when ALL of the bar VALUES in a series are set to ZERO, the chart displays the origin at the center of the left Y-Axis, with a line for each bar in the middle of the chart. How can I stop this behavior and make the zero bars display at the bottom of the chart (again this only happens when ALL of the bars are zero) as would be expected with the default origin set to zero, ie the bottom of the chart?
Thanks,
JT Taylor
Solution To TBarSeries ALL ZERO BARS Issue
Posted: Fri Apr 23, 2004 4:10 pm
by 5893652
Well, I found my own solution. But I have not determined which event to tap into yet. Probably the OnPaint Event of the Chart to set these properties or in the OnGetData event of the datasource or something like that. Anyhow, this issue stems from the automatic axis settings. When all values are zero, you need to set the Automatic Axis to False and the Min and Max Auto settings to False and set the Min to Zero and the Max to some positive vaule such as 10 or whatever is reasonable for the dataset you are working with. Then the zero bars display at the bottom of the grid with zero height as expected.
Posted: Tue Apr 27, 2004 1:32 pm
by 5893652
OnBeforeGenerate Event of the Report Builder Detail Band that contained the data-aware TeeChart component was the event to fire off my scale handling:
procedure Trpt_HBS0120.ppDetailBand5BeforeGenerate(Sender: TObject);
var
myVertAxis : TChartAxis;
minY, maxY: Double;
begin
inherited;
myVertAxis := ppDPTeeChart1.Chart[0].GetVertAxis;
minY := ppDPTeeChart1.Chart[0].MinYValue;
maxY := ppDPTeeChart1.Chart[0].MaxYValue;
AdjustScaleForAllZeroData(minY, maxY, myVertAxis);
myVertAxis := ppDPTeeChart1.Chart[1].GetVertAxis;
minY := ppDPTeeChart1.Chart[1].MinYValue;
maxY := ppDPTeeChart1.Chart[1].MaxYValue;
AdjustScaleForAllZeroData(minY, maxY, myVertAxis);
end;
procedure Trpt_HBS0120.AdjustScaleForAllZeroData(Min, Max : Double; VAxis : TChartAxis);
begin
if ((Min = 0) and (Max = 0)) then
begin
VAxis.Automatic := False;
VAxis.SetMinMax(0, 10);
end else
begin
VAxis.Automatic := True;
end;
end;