mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 09:19:22 +02:00
TAChart: Use styles for drawing stacked series
git-svn-id: trunk@27271 -
This commit is contained in:
parent
a1d8b1a7e8
commit
0006342434
@ -74,6 +74,7 @@ type
|
|||||||
property SeriesColor: TColor
|
property SeriesColor: TColor
|
||||||
read GetSeriesColor write SetSeriesColor stored false default clRed;
|
read GetSeriesColor write SetSeriesColor stored false default clRed;
|
||||||
property Source;
|
property Source;
|
||||||
|
property Styles;
|
||||||
property UseReticule;
|
property UseReticule;
|
||||||
property ZeroLevel: Double
|
property ZeroLevel: Double
|
||||||
read FZeroLevel write SetZeroLevel stored IsZeroLevelStored;
|
read FZeroLevel write SetZeroLevel stored IsZeroLevelStored;
|
||||||
@ -142,6 +143,7 @@ type
|
|||||||
property SeriesColor: TColor
|
property SeriesColor: TColor
|
||||||
read GetSeriesColor write SetSeriesColor stored false default clWhite;
|
read GetSeriesColor write SetSeriesColor stored false default clWhite;
|
||||||
property Source;
|
property Source;
|
||||||
|
property Styles;
|
||||||
property UseReticule;
|
property UseReticule;
|
||||||
property UseZeroLevel: Boolean
|
property UseZeroLevel: Boolean
|
||||||
read FUseZeroLevel write SetUseZeroLevel default false;
|
read FUseZeroLevel write SetUseZeroLevel default false;
|
||||||
@ -165,7 +167,7 @@ type
|
|||||||
FPointer: TSeriesPointer;
|
FPointer: TSeriesPointer;
|
||||||
FShowPoints: Boolean;
|
FShowPoints: Boolean;
|
||||||
|
|
||||||
procedure DrawSingleLineInStack(ACanvas: TCanvas);
|
procedure DrawSingleLineInStack(ACanvas: TCanvas; AIndex: Integer);
|
||||||
function GetShowLines: Boolean;
|
function GetShowLines: Boolean;
|
||||||
procedure SetLinePen(AValue: TPen);
|
procedure SetLinePen(AValue: TPen);
|
||||||
procedure SetLineType(AValue: TLineType);
|
procedure SetLineType(AValue: TLineType);
|
||||||
@ -202,6 +204,7 @@ type
|
|||||||
property ShowPoints: Boolean
|
property ShowPoints: Boolean
|
||||||
read FShowPoints write SetShowPoints default false;
|
read FShowPoints write SetShowPoints default false;
|
||||||
property Source;
|
property Source;
|
||||||
|
property Styles;
|
||||||
property UseReticule default true;
|
property UseReticule default true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -379,14 +382,14 @@ begin
|
|||||||
if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;
|
if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;
|
||||||
|
|
||||||
PrepareGraphPoints(ext, LineType <> ltFromOrigin);
|
PrepareGraphPoints(ext, LineType <> ltFromOrigin);
|
||||||
DrawSingleLineInStack(ACanvas);
|
DrawSingleLineInStack(ACanvas, 0);
|
||||||
for i := 0 to Source.YCount - 2 do begin
|
for i := 0 to Source.YCount - 2 do begin
|
||||||
UpdateGraphPoints(i);
|
UpdateGraphPoints(i);
|
||||||
DrawSingleLineInStack(ACanvas);
|
DrawSingleLineInStack(ACanvas, i + 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLineSeries.DrawSingleLineInStack(ACanvas: TCanvas);
|
procedure TLineSeries.DrawSingleLineInStack(ACanvas: TCanvas; AIndex: Integer);
|
||||||
var
|
var
|
||||||
points: array of TPoint;
|
points: array of TPoint;
|
||||||
pointCount: Integer = 0;
|
pointCount: Integer = 0;
|
||||||
@ -450,14 +453,19 @@ var
|
|||||||
SetLength(points, pointCount);
|
SetLength(points, pointCount);
|
||||||
SetLength(breaks, breakCount);
|
SetLength(breaks, breakCount);
|
||||||
|
|
||||||
ACanvas.Pen.Assign(LinePen);
|
if Styles = nil then
|
||||||
|
ACanvas.Pen.Assign(LinePen)
|
||||||
|
else
|
||||||
|
Styles.Apply(ACanvas, AIndex);
|
||||||
if Depth = 0 then
|
if Depth = 0 then
|
||||||
for i := 0 to High(breaks) - 1 do
|
for i := 0 to High(breaks) - 1 do
|
||||||
ACanvas.Polyline(points, breaks[i], breaks[i + 1] - breaks[i])
|
ACanvas.Polyline(points, breaks[i], breaks[i + 1] - breaks[i])
|
||||||
else begin
|
else begin
|
||||||
ACanvas.Brush.Style := bsSolid;
|
if Styles = nil then begin
|
||||||
ACanvas.Brush.Color := LinePen.Color;
|
ACanvas.Brush.Style := bsSolid;
|
||||||
ACanvas.Pen.Color := clBlack;
|
ACanvas.Brush.Color := LinePen.Color;
|
||||||
|
ACanvas.Pen.Color := clBlack;
|
||||||
|
end;
|
||||||
for i := 0 to High(breaks) - 1 do
|
for i := 0 to High(breaks) - 1 do
|
||||||
for j := breaks[i] to breaks[i + 1] - 2 do
|
for j := breaks[i] to breaks[i + 1] - 2 do
|
||||||
DrawLineDepth(ACanvas, points[j], points[j + 1], Depth);
|
DrawLineDepth(ACanvas, points[j], points[j + 1], Depth);
|
||||||
@ -691,14 +699,16 @@ end;
|
|||||||
|
|
||||||
procedure TBarSeries.Draw(ACanvas: TCanvas);
|
procedure TBarSeries.Draw(ACanvas: TCanvas);
|
||||||
|
|
||||||
procedure DrawBar(const AR: TRect);
|
procedure DrawBar(const AR: TRect; AIndex: Integer);
|
||||||
var
|
var
|
||||||
sz: TSize;
|
sz: TSize;
|
||||||
begin
|
begin
|
||||||
sz := Size(AR);
|
sz := Size(AR);
|
||||||
if (sz.cx > 2) and (sz.cy > 2) then
|
if Styles <> nil then
|
||||||
ACanvas.Pen.Assign(BarPen)
|
Styles.Apply(ACanvas, AIndex)
|
||||||
else begin
|
else
|
||||||
|
ACanvas.Pen.Assign(BarPen);
|
||||||
|
if (sz.cx <= 2) or (sz.cy <= 2) then begin
|
||||||
// Bars are too small to distinguish border from interior.
|
// Bars are too small to distinguish border from interior.
|
||||||
ACanvas.Pen.Color := ACanvas.Brush.Color;
|
ACanvas.Pen.Color := ACanvas.Brush.Color;
|
||||||
ACanvas.Pen.Style := psSolid;
|
ACanvas.Pen.Style := psSolid;
|
||||||
@ -717,7 +727,7 @@ var
|
|||||||
w, cumulHeight: Double;
|
w, cumulHeight: Double;
|
||||||
p: TDoublePoint;
|
p: TDoublePoint;
|
||||||
|
|
||||||
procedure BuildBar(AY: Double);
|
procedure BuildBar(AY: Double; AIndex: Integer);
|
||||||
var
|
var
|
||||||
graphBar: TDoubleRect;
|
graphBar: TDoubleRect;
|
||||||
imageBar: TRect;
|
imageBar: TRect;
|
||||||
@ -738,7 +748,7 @@ var
|
|||||||
if Bottom = Top then Dec(Top);
|
if Bottom = Top then Dec(Top);
|
||||||
if Left = Right then Inc(Right);
|
if Left = Right then Inc(Right);
|
||||||
end;
|
end;
|
||||||
DrawBar(imageBar);
|
DrawBar(imageBar, AIndex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -762,9 +772,9 @@ begin
|
|||||||
z := AxisToGraphY(ZeroLevel);
|
z := AxisToGraphY(ZeroLevel);
|
||||||
cumulHeight := z;
|
cumulHeight := z;
|
||||||
ACanvas.Brush.Color := GetColor(i);
|
ACanvas.Brush.Color := GetColor(i);
|
||||||
BuildBar(p.Y - z);
|
BuildBar(p.Y - z, 0);
|
||||||
for j := 0 to Source.YCount - 2 do
|
for j := 0 to Source.YCount - 2 do
|
||||||
BuildBar(Source[i]^.YList[j]);
|
BuildBar(Source[i]^.YList[j], j + 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
DrawLabels(ACanvas);
|
DrawLabels(ACanvas);
|
||||||
@ -1063,8 +1073,12 @@ begin
|
|||||||
prevPts[i] := pts[i];
|
prevPts[i] := pts[i];
|
||||||
numPrevPts := n2;
|
numPrevPts := n2;
|
||||||
|
|
||||||
ACanvas.Brush.Assign(AreaBrush);
|
if Styles = nil then begin
|
||||||
ACanvas.Pen.Assign(AreaContourPen);
|
ACanvas.Brush.Assign(AreaBrush);
|
||||||
|
ACanvas.Pen.Assign(AreaContourPen);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Styles.Apply(ACanvas, j);
|
||||||
if Depth > 0 then
|
if Depth > 0 then
|
||||||
// Rendering is incorrect when values cross zero level.
|
// Rendering is incorrect when values cross zero level.
|
||||||
for i := 1 to n2 - 2 do
|
for i := 1 to n2 - 2 do
|
||||||
|
Loading…
Reference in New Issue
Block a user