I see. This is a borderline case, probably too exotic to be included
in the general component.
Still, if you have inclination to work on a patch, I would suggest to change
TLineSeries.ShowLines property from boolean to enumeration
(slNone, slFromPrevious, slFromOrigin).
I created a patch (attached) introducing the property TLineType
TLineType = (ltFromPrevious, ltFromOrigin);
I left unchanged the ShowLines property also for retro compatibility.
I think that could be useful set the Origin in some way (a Origin
property?), by default Origin should be 0, 0 but could be changed by the
user. Do you think it is a good idea?
Anyway actually I don't know how to do it...
Another thing is that if the Chart points have for example XMax= 2 Xmin=
1 YMax =2 and YMin = 1 the Origin is not visible. How can I overcome
this problem? Actually I do it using XMax, Xmin etc of the Extent
property of the TAChart, do you think that is it the best way?
andrea
Index: taseries.pas
===================================================================
--- taseries.pas (revision 21842)
+++ taseries.pas (working copy)
@@ -140,17 +140,21 @@
ASender: TChartSeries; ACanvas: TCanvas; AIndex: Integer;
ACenter: TPoint) of object;
+ TLineType = (ltFromPrevious, ltFromOrigin);
+
{ TLineSeries }
TLineSeries = class(TBasicLineSeries)
private
FLinePen: TPen;
+ FLineType: TLineType;
FOnDrawPointer: TSeriesPointerDrawEvent;
FPointer: TSeriesPointer;
FShowLines: Boolean;
FShowPoints: Boolean;
procedure SetLinePen(AValue: TPen);
+ procedure SetLineType(const AValue: TLineType);
procedure SetPointer(Value: TSeriesPointer);
procedure SetShowLines(Value: Boolean);
procedure SetShowPoints(Value: Boolean);
@@ -191,6 +195,7 @@
read FOnDrawPointer write FOnDrawPointer;
property Pointer: TSeriesPointer read FPointer write SetPointer;
property SeriesColor;
+ property LineType: TLineType read FLineType write SetLineType default
ltFromPrevious;
property ShowLines: Boolean read FShowLines write SetShowLines default
true;
property ShowPoints: Boolean read FShowPoints write SetShowPoints default
false;
property Source;
@@ -344,23 +349,45 @@
a, b: TDoublePoint;
begin
if FShowLines then
- for i := 0 to Count - 2 do begin
- a := DoublePoint(Source[i]^);
- b := DoublePoint(Source[i + 1]^);
- if not LineIntersectsRect(a, b, ParentChart.CurrentExtent) then continue;
- ai := ParentChart.GraphToImage(a);
- bi := ParentChart.GraphToImage(b);
- ACanvas.Pen.Assign(LinePen);
- if Depth = 0 then
- ACanvas.Line(ai, bi)
- else begin
- ACanvas.Brush.Style := bsSolid;
- ACanvas.Brush.Color := ACanvas.Pen.Color;
- ACanvas.Pen.Color := clBlack;
- DrawLineDepth(ACanvas, ai, bi, Depth);
+ begin
+ case FLineType of
+ ltFromPrevious :
+ for i := 0 to Count - 2 do begin
+ a := DoublePoint(Source[i]^);
+ b := DoublePoint(Source[i + 1]^);
+ if not LineIntersectsRect(a, b, ParentChart.CurrentExtent) then
continue;
+ ai := ParentChart.GraphToImage(a);
+ bi := ParentChart.GraphToImage(b);
+ ACanvas.Pen.Assign(LinePen);
+ if Depth = 0 then
+ ACanvas.Line(ai, bi)
+ else begin
+ ACanvas.Brush.Style := bsSolid;
+ ACanvas.Brush.Color := ACanvas.Pen.Color;
+ ACanvas.Pen.Color := clBlack;
+ DrawLineDepth(ACanvas, ai, bi, Depth);
+ end;
end;
+ ltFromOrigin :
+ for i := 0 to Count - 1 do begin
+ a := DoublePoint(Source[i]^);
+ b.X:= 0;
+ b.Y:= 0;
+ if not LineIntersectsRect(a, b, ParentChart.CurrentExtent) then
continue;
+ ai := ParentChart.GraphToImage(a);
+ bi := ParentChart.GraphToImage(b);
+ ACanvas.Pen.Assign(LinePen);
+ if Depth = 0 then
+ ACanvas.Line(ai, bi)
+ else begin
+ ACanvas.Brush.Style := bsSolid;
+ ACanvas.Brush.Color := ACanvas.Pen.Color;
+ ACanvas.Pen.Color := clBlack;
+ DrawLineDepth(ACanvas, ai, bi, Depth);
+ end;
+ end;
end;
-
+ end;
DrawLabels(ACanvas, true);
if FShowPoints then
@@ -479,6 +506,13 @@
FLinePen.Assign(AValue);
end;
+procedure TLineSeries.SetLineType(const AValue: TLineType);
+begin
+ if FLineType=AValue then exit;
+ FLineType:=AValue;
+ UpdateParentChart;
+end;
+
function TLineSeries.GetColor(AIndex: Integer): TColor;
begin
Result := ColorOrDefault(Source[AIndex]^.Color);
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus