I have 2 TCharts, A and B, each displaying a TIsoSurfaceSeries. I have a trackbar T with the following OnChange handler:
A.View3DOptions.Elevation := T.Position;
B.View3DOptions.Elevation := T.Position;
and I drag the trackbar around. One of the charts updates smoothly immediately, the other only when I stop dragging. I need both to update immediately as I'm working on an application where the user can make modifications and see the effects on two different 3D charts simultaneously.
I tried deleting one chart and recreating it, and now this one is the one that updates smoothly, while the other lags.
Can you please tell me how I can smoothly and immediately have 2 TCharts respond to a change in e.g. View3DOptions.Elevation or anything else that affects the chart's visual state?
Thanks. Jim.
Updating two 3-d charts
Hi Jim,
The only way we can think to solve that is changing the elevation of each chart by concurrency.
Here there is an example doing that. We create a thread for each chart when the trackbar is scrolled. And in each thread the elevation is updated.
I hope it helps.
The only way we can think to solve that is changing the elevation of each chart by concurrency.
Here there is an example doing that. We create a thread for each chart when the trackbar is scrolled. And in each thread the elevation is updated.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, TeeSurfa, ComCtrls, ExtCtrls, TeeProcs, Chart,
StdCtrls;
type
TMyThread = class(TThread)
private
CChart : TChart;
Elevation: Integer;
public
constructor Create(CreateSuspended: Boolean; ChartLink : TChart; ElevationNum : Integer);
procedure Execute; override;
end;
type
TForm1 = class(TForm)
Chart1: TChart;
Chart2: TChart;
TrackBar1: TTrackBar;
Series1: TIsoSurfaceSeries;
Series2: TIsoSurfaceSeries;
procedure TrackBar1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
thr1, thr2 : TMyThread;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3DOptions.Orthogonal := false;
Chart2.View3DOptions.Orthogonal := false;
TrackBar1.Max := 360;
TrackBar1.Min := 270;
TrackBar1.Position := Chart1.View3DOptions.Elevation;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
thr1 := TMyThread.Create(true, Chart1, TrackBar1.Position);
thr2 := TMyThread.Create(true, Chart2, TrackBar1.Position);
thr1.Resume;
thr2.Resume;
end;
constructor TMyThread.Create(CreateSuspended: Boolean; ChartLink : TChart; ElevationNum : Integer);
begin
CChart := ChartLink;
Elevation := ElevationNum;
inherited Create(CreateSuspended);
end;
procedure TMyThread.Execute;
begin
CChart.View3DOptions.Elevation := Elevation;
end;
end.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 12
- Joined: Thu Oct 11, 2007 12:00 am
Nope...
This doesn't change anything. Actually, after implementing it, I can't see why it would. The issue seems to be that, internally, only one chart wants to be updating at a time and someone, one of them takes precedence. I tried the following experiment. I deleted the one that was "lagging" and recreated it on my form, and ran the program again...now the NEWLY-created one is the one that gets preferentially updated.
Any other thoughts? Jim.
Any other thoughts? Jim.
Hi Jim,
I've sent to your mail account an example. You can see on it the problem you have with the "lag" moving the trackbar and there's a checkbox to do the same by concurrency.
Can't you see any difference? Could you please tell me what TeeChart version are you using?
I've sent to your mail account an example. You can see on it the problem you have with the "lag" moving the trackbar and there's a checkbox to do the same by concurrency.
Can't you see any difference? Could you please tell me what TeeChart version are you using?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 12
- Joined: Thu Oct 11, 2007 12:00 am
Again
They do EXACTLY the same thing: one chart always lags the other, unless you move the trackbar VERY slowly.
I found, though, that this works:
Chart1.View3dOptions.Elevation := x;
Chart1.Repaint;
Chart2.View3dOptions.Elevation := x;
Chart2.Repaint;
You need BOTH Repaint calls or it's still the same behavior (I had initially tried with only the middle Repaint and had given up).
Delphi 2007 11.0.2804.9245 Win32 and TeeChart 8.10.10844 Win32.
Thanks. Jim.
I found, though, that this works:
Chart1.View3dOptions.Elevation := x;
Chart1.Repaint;
Chart2.View3dOptions.Elevation := x;
Chart2.Repaint;
You need BOTH Repaint calls or it's still the same behavior (I had initially tried with only the middle Repaint and had given up).
Delphi 2007 11.0.2804.9245 Win32 and TeeChart 8.10.10844 Win32.
Thanks. Jim.