ZoomControl: Issues with handling lots of data

In my program I run a thread which continously acquires data from an USB device, evaluates it and adds the result to my Line Chart (see my other thread). So the chart grows and grows and grows ...


For better overview and handling I thought it is a good idea to work with the ZoomControl class provided by the TMS GDI+ Chart. But the more I (try to) implement it, the more I get frustrated.

Before switching to TMS Chart I was working with the default TChart component which comes with Delphi. TChart has a very simple and yet useful zoom: You just could just drag a rectangle to zoom an area. If you dragged it from left to right you zoomed in. If you dragged it from right to left you zoomed out. But somehow I'm missing this functionality in the TMS Chart.

Additionally the TMS Chart manual seems to lack documentation of properties, events and methods of the TAdvGDIPChartView.

http://www.tmssoftware.biz/download/manuals/TMS%20TADVCHART.pdf

But now to the problem:

The following screenshot displays a diagram with the ZoomControl below it. It has ~1000 points.



As you can see the ZoomControl is already heavily packed and confusing as it displays the range from 0 to 1000. Also the slider zoom handle grows thiner and thiner
// procedure TMainForm.AddData(Data: TRTW_TrialData);
rLen := Length(Chart.Panes[0].Series[0].Points);



rFrom := rLen - 10;
rTo := rLen;



Chart.Panes[0].Range.RangeFrom := rFrom;
Chart.Panes[0].Range.RangeTo := rTo;


Chart.Panes[0].ZoomControl.SlideMinimumRange := 0;
Chart.Panes[0].ZoomControl.SlideMaximumRange := rTo;


Chart.Panes[0].ZoomControl.SlideRangeFrom := rFrom;
Chart.Panes[0].ZoomControl.SlideRangeTo := rTo;


But thats not the problem. The problem is:

When I stop the data acquisition thread to "scroll" through the chart the following happens (even with lot less points, like ~300):

1) As soon as I drag the center of the Slider Handle (to move the whole slider) the chart switches to display only 1 point, even though it should display at least 10 points.

Please note the debug output "315; 325" in the top-left corner. Thats the range it SHOULD display. So I have no idea why it only displays 1 point then.



2) When I then try and drag the LEFT handle of the Slider the chart suddenly switches to display ALL points, even though it should only display a range of 313-325 (see debug output 313; 325).



3) When trying to drag the RIGHT Slider handle the chart goes empty. (Note debug output)



4) Changing the range of the Slider Handle has no effect at all. The results are either: A) Display ALL, B) display 1 or C) display none. (Debug output 55 - 292).



So I thought it helps when I add some code to the OnZoomControlRangeChanged and OnZoomControlRangeChanging events.
procedure TMainForm.ChartZoomControlRangeChanged(Sender: TObject; PaneIndex, RangeFrom, RangeTo: Integer);
begin
  Label3.Caption :=
  	IntToStr(RangeFrom) + '; ' +
  	IntToStr(RangeTo);


{  Chart.Panes[0].Range.RangeFrom := RangeFrom;
  Chart.Panes[0].Range.RangeTo := RangeTo;}
end;


procedure TMainForm.ChartZoomControlRangeChanging(Sender: TObject; PaneIndex, RangeFrom, RangeTo: Integer);
begin
  CheckBox_AutoScroll.Checked := FALSE;


  Label3.Caption :=
  	IntToStr(RangeFrom) + '; ' +
  	IntToStr(RangeTo);


{  Chart.Panes[0].Range.RangeFrom := RangeFrom;
  Chart.Panes[0].Range.RangeTo := RangeTo;}
end;

Please note that I already commented out the test code because it didn't help and only made the chart behave even worse and I don't want to bother you with even more screenshots.

For me it seems like the ZoomControl class is somehow broken and unable the handle "alot" of data properly. And by "alot" I mean that it seems to be overwhelmed by even >100 or >200 entries.

Why can't the ZoomControl be simple, intelligent and easy? And by intelligent I mean something like that it is able to recognize when it displays quite a bunch of data and instead of "squeezing" it all together just "scroll" it.

There is so much trial 'n error involved due to the lack of documentation and examples that I really think to just switch back to TChart. I'm fighting with that overall TMS Zoom problem already since like 2 or 3 working days and it is just frustrating ... :/

Hi, 


Could you perhaps prepare and send us a sample with your data, so we can investigate this here?
We are unaware of issues with the zoomcontrol, and it will be helpful to investigate this here with correct data and settings.

Kind Regards, 
Pieter

Here you go: https://dl.dropboxusercontent.com/u/16274518/TMSGDIPChart_ZoomControl_Test.zip

Hi, 


Thank you for your sample, 
Can you add the following line to your code:

procedure TForm1.AddData(Sender: TObject; Value: Extended);
var
rLen, rFrom, rTo: Integer;
begin
  Chart.BeginUpdate;
  try
    rLen := Length(Chart.Panes[0].Series[0].Points);

    rFrom := rLen - 10;
    rTo := rLen;

    if rFrom < 0 then
    rFrom := 0;

    Chart.Panes[0].Range.RangeFrom := rFrom;
    Chart.Panes[0].Range.RangeTo := rTo;

    Chart.Panes[0].ZoomControl.AutoUpdate := auImmediate;

    Chart.Panes[0].ZoomControl.SlideMinimumRange := 0;
    Chart.Panes[0].ZoomControl.SlideMaximumRange := rTo;

    Chart.Panes[0].ZoomControl.SlideRangeFrom := rFrom;
    Chart.Panes[0].ZoomControl.SlideRangeTo := rTo;
-->    Chart.Panes[0].ZoomControl.Chart.Range.MaxRangeTo := rTo;

    Chart.Panes[0].Series[0].AddSinglePoint(Value);
    Chart.Panes[0].Series[1].AddSinglePoint(Value);
  finally
  Memo1.Lines.Add('[' + IntToStr(rLen) + '] Value = ' + FloatToStr(Value));
    Chart.EndUpdate;
  end;
end;

We will continue investigation here, why the MaxRangeTo property of the chart. It might be possible that this property is added after the zoomcontrol was added, and that the MaxRangeTo property isn't yet synchronized with the ZoomControl SlideMaximumRange.

Kind Regards, 
Pieter