Tchart, weird plotting when zooming

220 views Asked by At

So I have this fine legacy Delphi 5 project with a tchart with vertical bars along a datetime bottomaxis. It works very fine. Now I want to add up to three horizontal "warning"-lines, each with up to three togglable labels. The idea is to show three red limit lines(three 3-element lineseries), and labels at far left, middle and far right showing Yvalue limits. Labels are togglable in order not to clutter data. And it works too. These labels must sit at xmin, mid and xmax even when scrolling. I solved it with having a timer started when first dataseries is redrawn, and then resetting the three labelseries with the chart's new xmin, mid, xmax. When scrolling, the labels follow. But when I zoom in, something is lost. I print the xmin, xmax and line coordinates in the statusbar as it is recalculated (for debugging), it looks quite right, but the three horizontal lines slip away to the left. Leftmost point is out of sight, rightmost is drifting to the left, worse with increased zoom. Yvalues are correct.

Is there a best way to do plot-eventdriven recalculation of plotdata? (Or must I rebuild it all in my XE10.2? )

1

There are 1 answers

0
P Oltergeist On

I just ran it at home, the same phenomenon appears in XE10.2. When I zoom in, the second series (horizontal line, endpoints recalculated to be at the graph's edges) creeps away to the side. However if I connect series2 to Topaxis, then everything is fine. Rock solid. Seems like a natural thing. Silly me.

procedure TForm1.Series1AfterDrawValues(Sender: TObject); 
var a,b :Double; 
begin 
a:=(Chart1.LeftAxis.Minimum+chart1.leftAxis.maximum)/2; 
b:=chart1.TopAxis.Minimum; 
series2.Clear; 
series2.addxy(b,a,'Left'); 
series2.addxy(b+(chart1.topAxis.Maximum-b)/2,a,'Mid');
series2.addxy(chart1.topAxis.Maximum,a,'Right'); 
end;

Running,line stays put when scrolling