From edd774a031f68ca30ab9894dd4bfaf60d1db0d1e Mon Sep 17 00:00:00 2001 From: ask Date: Sun, 8 Aug 2010 06:37:15 +0000 Subject: [PATCH] TAChart: Add TBarSeries.ZeroLevel property git-svn-id: trunk@27031 - --- components/tachart/taseries.pas | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/components/tachart/taseries.pas b/components/tachart/taseries.pas index 02b64780a1..46fec7957d 100644 --- a/components/tachart/taseries.pas +++ b/components/tachart/taseries.pas @@ -74,12 +74,15 @@ type FBarBrush: TBrush; FBarPen: TPen; FBarWidthPercent: Integer; + FZeroLevel: Double; function CalcBarWidth(AX: Double; AIndex: Integer): Double; + function IsZeroLevelStored: boolean; procedure SetBarBrush(Value: TBrush); procedure SetBarPen(Value: TPen); procedure SetBarWidthPercent(Value: Integer); procedure SetSeriesColor(AValue: TColor); + procedure SetZeroLevel(AValue: Double); protected procedure GetLegendItems(AItems: TChartLegendItems); override; function GetSeriesColor: TColor; override; @@ -101,6 +104,8 @@ type read GetSeriesColor write SetSeriesColor default clTAColor; property Source; property UseReticule; + property ZeroLevel: Double + read FZeroLevel write SetZeroLevel stored IsZeroLevelStored; end; { TPieSeries } @@ -890,9 +895,9 @@ begin p := FGraphPoints[i - FLoBound]; w := CalcBarWidth(GetGraphPointX(i), i); if IsRotated then - graphBar := DoubleRect(AxisToGraphX(0), p.Y - w, p.X, p.Y + w) + graphBar := DoubleRect(AxisToGraphX(ZeroLevel), p.Y - w, p.X, p.Y + w) else - graphBar := DoubleRect(p.X - w, AxisToGraphY(0), p.X + w, p.Y); + graphBar := DoubleRect(p.X - w, AxisToGraphY(ZeroLevel), p.X + w, p.Y); if not RectIntersectsRect(graphBar, ext2) then continue; with imageBar do begin @@ -917,7 +922,7 @@ var begin Result := inherited Extent; if IsEmpty then exit; - UpdateMinMax(0, Result.a.Y, Result.b.Y); + UpdateMinMax(ZeroLevel, Result.a.Y, Result.b.Y); // Show first and last bars fully. x := GetGraphPointX(0); Result.a.X := Min(Result.a.X, x - CalcBarWidth(x, 0)); @@ -935,6 +940,11 @@ begin Result := FBarBrush.Color; end; +function TBarSeries.IsZeroLevelStored: boolean; +begin + Result := ZeroLevel <> 0.0; +end; + procedure TBarSeries.SetBarBrush(Value: TBrush); begin FBarBrush.Assign(Value); @@ -957,6 +967,13 @@ begin FBarBrush.Color := AValue; end; +procedure TBarSeries.SetZeroLevel(AValue: Double); +begin + if FZeroLevel = AValue then exit; + FZeroLevel := AValue; + UpdateParentChart; +end; + { TPieSeries } function TPieSeries.AddPie(Value: Double; Text: String; Color: TColor): Longint;