TAChart: Fix mark positions for bar series with BarOffsetPercent <> 0

git-svn-id: trunk@39130 -
This commit is contained in:
ask 2012-10-18 16:15:17 +00:00
parent 8a9d23c7e6
commit 1e0cb7d080
2 changed files with 19 additions and 2 deletions

View File

@ -241,13 +241,14 @@ type
FUseReticule: Boolean;
strict protected
procedure DrawLabels(ADrawer: IChartDrawer);
function GetLabelDataPoint(AIndex: Integer): TDoublePoint; virtual;
procedure UpdateGraphPoints(AIndex: Integer); overload; inline;
procedure UpdateGraphPoints(AIndex, ALo, AUp: Integer); overload;
protected
procedure AfterAdd; override;
procedure AfterDrawPointer(
ADrawer: IChartDrawer; AIndex: Integer; const APos: TPoint); virtual;
procedure DrawLabels(ADrawer: IChartDrawer);
procedure DrawPointers(ADrawer: IChartDrawer);
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
function GetXRange(AX: Double; AIndex: Integer): Double;
@ -943,7 +944,7 @@ var
begin
if not Marks.IsMarkLabelsVisible then exit;
for i := 0 to Count - 1 do begin
g := GetGraphPoint(i);
g := GetLabelDataPoint(i);
ld := GetLabelDirection(i);
for si := 0 to Source.YCount - 1 do begin
if si > 0 then
@ -978,6 +979,11 @@ begin
end;
end;
function TBasicPointSeries.GetLabelDataPoint(AIndex: Integer): TDoublePoint;
begin
Result := GetGraphPoint(AIndex);
end;
function TBasicPointSeries.GetLabelDirection(AIndex: Integer): TLabelDirection;
const
DIR: array [Boolean, Boolean] of TLabelDirection =

View File

@ -70,6 +70,8 @@ type
procedure SetOnBeforeDrawBar(AValue: TBeforeDrawBarEvent);
procedure SetSeriesColor(AValue: TColor);
procedure SetZeroLevel(AValue: Double);
strict protected
function GetLabelDataPoint(AIndex: Integer): TDoublePoint; override;
protected
procedure GetLegendItems(AItems: TChartLegendItems); override;
function GetSeriesColor: TColor; override;
@ -961,6 +963,15 @@ begin
Result := Abs(f(2 * w) - f(0));
end;
function TBarSeries.GetLabelDataPoint(AIndex: Integer): TDoublePoint;
var
ofs, w: Double;
begin
Result := inherited GetLabelDataPoint(AIndex);
BarOffsetWidth(TDoublePointBoolArr(Result)[IsRotated], AIndex, ofs, w);
TDoublePointBoolArr(Result)[IsRotated] += ofs;
end;
procedure TBarSeries.GetLegendItems(AItems: TChartLegendItems);
begin
GetLegendItemsRect(AItems, BarBrush);