Alexander Klenin wrote:
BTW, did you test events for TDataPointDragTool?
I have implemented a different set of events than
you suggested -- are they enough for your use case?
The mailing list seems to be running really slow lately, almost as if
it's only processing mail in nightly batches.
I did do a quick and basic experiment with the drag tool events
and they work great for my purposes =]  (and probably everybody's
future use cases as well).  Thanks!

I really needed a stairstep series, and I found it much easier to
implement in the line series rather than the area series.
(The bar graph series also does not respect linear offset transformation,
by the way.)  I'll paste a unified diff so you can see what I did to the
line series.  It's really quite basic and not particularly elegant, but it
works great.  I didn't add reverse stairs since I don't need them, but
it's only another three lines of code.

I'm having a little bit of trouble with my axis labels.  TAChart seems to
only want to display even numbers on the horizontal axis, for example.
Even when I use a custom source and set it to X values, it only shows
the even numbers.  What am I missing?

Another thing I noticed is that performance is pretty bad with 32 line
series.  I'm not sure what the bottleneck is yet.  I'm guessing that it's
floating-point math and thinking about trying a custom integer-based
series.  Any thoughts on that?

Well here's my version of a line-based stair series:


VC: In print_context_label
--- \LazarusSVN\components\tachart\taseries.pas Mon May 31 06:37:02 2010
VC: In print_context_label
+++ \lazarus2\components\tachart\taseries.pas   Wed Jun 02 23:38:06 2010
@@ -171,6 +171,7 @@
    FOnDrawPointer: TSeriesPointerDrawEvent;
    FPointer: TSeriesPointer;
    FShowPoints: Boolean;
+    FStairs: Boolean;

    function GetShowLines: Boolean;
    procedure SetLinePen(AValue: TPen);
@@ -179,6 +180,7 @@
    procedure SetSeriesColor(AValue: TColor);
    procedure SetShowLines(Value: Boolean);
    procedure SetShowPoints(Value: Boolean);
+    procedure SetStairs(Value: Boolean);
  protected
    procedure AfterAdd; override;
    procedure GetLegendItems(AItems: TChartLegendItems); override;
@@ -208,6 +210,7 @@
    property ShowPoints: Boolean
      read FShowPoints write SetShowPoints default false;
    property Source;
+    property Stairs: Boolean read FStairs write SetStairs default false;
    property UseReticule default true;
  end;

@@ -379,6 +382,28 @@
    ai := ParentChart.GraphToImage(AA);
    bi := ParentChart.GraphToImage(AB);
    ACanvas.Pen.Assign(LinePen);
+    if Stairs then
+    begin
+      if bi.Y = ai.Y then
+      begin
+        ACanvas.Line(ai, bi);
+      end
+      else
+      begin
+        if ai.Y < bi.Y then  // Step down
+        begin
+          ACanvas.Line(bi, point(bi.X, ai.Y));
+          ACanvas.Line(point(bi.X, ai.Y), ai);
+        end
+        else                 // Step up
+        begin
+          ACanvas.Line(ai, point(bi.X, ai.Y));
+          ACanvas.Line(point(bi.X, ai.Y), bi);
+        end;
+      end;
+    end
+    else
+    begin
    if Depth = 0 then
      ACanvas.Line(ai, bi)
    else begin
@@ -387,6 +412,7 @@
      ACanvas.Pen.Color := clBlack;
      DrawLineDepth(ACanvas, ai, bi, Depth);
    end;
+   end;
  end;

var
@@ -474,6 +500,12 @@
procedure TLineSeries.SetShowPoints(Value: Boolean);
begin
  FShowPoints := Value;
+  UpdateParentChart;
+end;
+
+procedure TLineSeries.SetStairs(Value: Boolean);
+begin
+  FStairs := Value;
  UpdateParentChart;
end;

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to