Page 1 of 2

TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 11:04 am
by 16561863
Hi Narcis,

I need your help again.
I have read and applied the "Real-time Charting article" and it did not solve the speed problem.
In fact i compared the loading time : "No optimization VS Optimization" the difference in my case is around 10 ms.
Then i noticed that the problem is not at all in loading the data!
In fact i have the feeling that the CPU is tremendously used !.
When i press a button on the same form as the TChart it responds but after a very long period of time : 10 Seconds Just to show a "Hello" message !.
Then, since i can not debug in the Mac side, i tried to debug In windows side ( where there is no speed problem at all !) .
By putting a showmessage on BeforeDraw and on AfterDraw i noticed that drawing keeps get called every time, as soon as you move the mouse, consuming CPU which is ok on windows but not on ios. Please note that no data has been modified or a form resized, just moving the mouse !
I hope that you can find a workaround to not let the TChart be redrawed unnecessarily !

Thanks
r.lebbar

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 1:02 pm
by yeray
Hi r.lebbar,
rlebbar wrote:By putting a showmessage on BeforeDraw and on AfterDraw i noticed that drawing keeps get called every time, as soon as you move the mouse, consuming CPU which is ok on windows but not on ios. Please note that no data has been modified or a form resized, just moving the mouse !
I hope that you can find a workaround to not let the TChart be redrawed unnecessarily !
I'm trying to reproduce this in XE2 and the actual sources in a Win7 x64 machine but it seems to work fine for me here. Find attached the application I'm using.
iOS test.zip
(3.62 KiB) Downloaded 1602 times
When the application starts, I see a call to both OnBeforeDrawChart and OnAfterDraw events but not when I move the mouse over the chart once it is shown.

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 2:18 pm
by 16561863
Hi Yeray

Please look at this image !

Thanks

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 2:59 pm
by yeray
Hi r.lebbar,

This is not just moving the mouse over the chart but pressing the left mouse button down and then moving the mouse to draw the zoom rectangle, isn't it?
To draw the zoom rectangle, the chart has to be redrawn.

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 3:17 pm
by 16561863
Hi Yeray

Sorry Yeray, This is JUST MOVING THE MOUSE over the chart : No Click, No left Button, No Right Button !

Thanks

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 3:41 pm
by 16561863
Hi Yeray

I have not noticed a rectangle in the back that stays active
Please find the exe i have generated with your code

Thanks

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 3:48 pm
by 16561863
Hi Yearay

The Exe Project was not allowed to be uploaded.

Thanks

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 3:50 pm
by narcis
Hello,

If compressing it in a zip/rar package doesn't fit in the maximum upload size (512 kb) please upload it at http://www.steema.net/upload/.

Thanks in advance.

Re: TeeChart Speed on IOS

Posted: Wed Mar 14, 2012 3:59 pm
by 16561863
Hi Narcis,

I have uploaded the exe file as indicated.
Please in the mean time what about the ios device, since i am more interested in the ios than the windows projects

Thanks

Re: TeeChart Speed on IOS

Posted: Thu Mar 15, 2012 12:57 pm
by yeray
Hi r.lebbar,

I'm still a little bit confused.
- The exe you sent us responds to me as I'd expect: before the first time the chart is going to be shows, both events are fired once. Then, once the chart is shown, I can move the window and move the mouse over the chart without clicking on it, and the events aren't fired. Only if I click on the chart, then it is redrawn and the events are fired again and again as I move the mouse because it needs to draw the zoom rectangle.

- In a real device, "moving the mouse over the chart without clicking on it" has no sense (at least I don't see it). So, if you are moving the finger around the chart *touching the chart*, the equivalent in windows would be clicking on the chart and moving the mouse. Then, as said above, by default, a zoom rectangle is being drawn and thus the charts is resized each time a mouse/finger displacement is being detected to draw a new zoom rectangle.

Try disabling the zoom feature:

Code: Select all

Chart1.AllowZoom:=false;

Re: TeeChart Speed on IOS

Posted: Sun Mar 18, 2012 11:51 pm
by 16561863
Hi yeray

Sorry for the delay, i was out of town.
Please find a sample that will show you exactly what is happening
In my case then variable "NbreOfTimesTheChartIsDrawn" increments by 5 or 6 at each hit !

Thanks
r.lebbar

Re: TeeChart Speed on IOS

Posted: Mon Mar 19, 2012 3:36 pm
by yeray
Hi r.lebbar,

Interesting. If I click on the button with the mouse it behaves as you describe (increments by 5 or 6 at each hit). But if I press the space bar (after one click with the mouse so the focus is in the button), the NbreOfTimesTheChartIsDrawn remains stable.
And the same happens if I use the chart Clicked event:

Code: Select all

procedure TForm1.Chart1Click(Sender: TObject);
begin
  ShowMessageFmt('So far, the Chart has been drawn %d Times',[NbreOfTimesTheChartIsDrawn]);
end;
Could you please confirm with this the number of times the chart is drawn seems to be stable?
It would indicate that clicking the button makes the chart to be redrawn

Re: TeeChart Speed on IOS

Posted: Mon Mar 19, 2012 5:49 pm
by 16561863
Hi Yeray

The OnChartClick seems to be more stable than the SpeedButtonClick.
But as you may notice when you click on the chart the very first time it gets redrawn once more (only the first click).

With the SpeedButtonClick it is worst since the Chart is redrawn more than 5 Times at each click.

Could you please help me get a very basic workaround since in my case there is no reason to let the chart be redrawn once the OnAfterDraw event is hit. So the question is how to freeze the chart ? (Not allowing it to be redrawn).

Thanks in advance.
r.lebbar

Re: TeeChart Speed on IOS

Posted: Tue Mar 20, 2012 10:28 am
by yeray
Hi r.lebbar,

TButton is also stable. It actually seems to be a non related TeeChart problem: if you remove the chart and use the Form OnPaint event instead of the chart OnBeforeDrawChart/OnAfterDraw events, it behaves exactly the same:

Code: Select all

procedure TForm1.FormPaint(Sender: TObject; Canvas: TCanvas;
  const ARect: TRectF);
begin
  Inc(NbreOfTimesTheChartIsDrawn);
end;
I've opened a ticket in Embarcadero's Quality Central. You can vote for it.
http://qc.embarcadero.com/wc/qcmain.aspx?d=104281

In the meanwhile I'd suggest you to use TButton instead of TSpeedButton.

Re: TeeChart Speed on IOS

Posted: Fri Mar 23, 2012 9:42 am
by 16561863
Hi Yeray

Thanks for your help, I have finally a decent loading time !

By using a Private variable fIsAlreadyDrawn in the Form, one can do :
procedure TFChart.TestChartAfterDraw(Sender: TObject);
begin
fIsAlreadyDrawn := True;
end;
procedure TFChart.TestChartBeforeDrawChart(Sender: TObject);
begin
if fIsAlreadyDrawn Then Abort
end;
This works on Windows but not on the real IOS device.
Then I added a property variable IsAlreadyDrawn to the Chart in the FMI code.
It drops by arround 50% the necessary time to load the chart .
I know that this is just a workaround until a real solution is found.

Many Thanks.
r.lebbar