-1

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? )

  • Your program is surely fixable without a massive delphi upgrade. That would probably be a huge task. We can't help if you don't provide detail. Good luck. – David Heffernan Sep 11 '17 at 18:45
  • I don't know what TeeChart version are you using, but TeeChart Pro has a `TColorLine` that helps you to do all this. If you have to handle it with the events, note you may have to force a chart `Repaint` (or `Draw`) at the beginning of some of them (ie `OnZoom`) to have the correct internal values. – Yeray Sep 12 '17 at 07:49
  • D5 is from 1999 so a lot of todays functionality is lacking. This may be a bug, or maybe I "plot along with the previous end coordinates" since the horizontal lines are continously adjusted. Just looking for a workaround. Thanks, I'll consider your suggestion. – P Oltergeist Sep 12 '17 at 09:37

1 Answers1

0

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