Page 1 of 1
Dynamic line...
Posted: Fri Nov 24, 2006 7:18 am
by 8577300
Hello again!!
http://www.bos.at/downloads/Chart.jpg
I want to show only a part of my data in the chart....the rest of my data is invisible behind the right axis.
I want to realize the following steps:
1) The white line (its a 'orientation line' for the current position on my chart) which i draw in the middle of the chart should be on the left side before I push a button. Thats my initial position...
2) After pushing the button (a timer will be started in the background) the white line should move its position on the timeline (x-axis) till it reaches the middle of the chart.
3) After this datalines of my 2 series should move from right to left so that the user always see the current data at the white line.
4) When the end of my data will shown then the white line should move from the middle to the right end. When the line reaches the right axis then the current data is the last one.
I hope I could explain it in a understanding way??!!
Can I realize this in that way?? I'm happy about any idea or tipp how I can realize this!!
Bye
Thomas
Posted: Fri Nov 24, 2006 9:38 am
by narcis
Hi Thomas,
Please find below the answers to your questions:
1. I'd use a TColorLineTool for the vertical white line. A the code below snippet below, in the OnFormCreate event, the line is positioned at the left of the chart.
2. In the snippet below, after pressing the button a timer is enabled, new data is added to the series and the line positions itself to the center of the chart.
3. For this I'd use something as in the interpolating example I posted
here.
4. I don't know exactly how would you like to differentiate between question 3 situation and this but at the timer event in the snippet below, after the series reaches 100 points the line is positioned at the right of the axis.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues();
Series2.FillSampleValues();
ChartTool1.Value:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Center: double;
begin
Series1.Add(random*1000);
Series2.Add(random*1000);
Center:=Chart1.Axes.Bottom.Minimum + ((Chart1.Axes.Bottom.Maximum -
Chart1.Axes.Bottom.Minimum)/2);
if ChartTool1.Value < Center then
ChartTool1.Value:=ChartTool1.Value+5;
if Series1.Count >=100 then
begin
Timer1.Enabled:=false;
Chart1.Draw;
ChartTool1.Value:=Chart1.BottomAxis.Maximum;
end;
end;
Posted: Fri Nov 24, 2006 10:20 am
by 8577300
Hello Narcis!!
To question 4) Each data (of series1, series2) has its time....
For e.g.:
I have measured data (x,y) 60 secs long and my window display a time of 20secs. The orientation-line at startup on the left side and went after starting till to the middle of the chart. So after 10 secs. (half of chart display) the line is at the middle.
So I know that my data captured for 60 secs and so the orientation-line have to move at sec. 50 from the middle to the right side, that at sec. 60 the line reaches the end of data on the right axis...
So I imagine....
Posted: Mon Nov 27, 2006 7:28 am
by 8577300
Hello Narcis!!
I tried out the TColorLineTool but I always get an access-violation-exception when I use the tool.
I implemented a private variable in the type-header like this:
and want to set the value under onFormShow like this:
Whats the reason??
Bye
Thomas
Posted: Mon Nov 27, 2006 7:42 am
by Marjan
Hi.
How did you create and connect linetool to chart ? The following code works just fine:
Code: Select all
var line: TColorLineTool;
begin
line := TColorLineTool.Create(Chart1);
Chart1.Tools.Add(line);
line.Value := 0;
line.Axis := Chart1.Axes.Bottom;
Posted: Mon Nov 27, 2006 8:04 am
by 8577300
Hello Marjan,
thank you for your code...I solved my question when I took a look in the settings of my chart and found the tools...but its interesting to see how I also can set a ColorLineTool at runtime...many thanks!!
Bye
Thomas
Posted: Mon Nov 27, 2006 8:34 am
by 8577300
My x-axis is a timeline with values in TDateTime-Format...
Is there a possibility to get the current position on the x-axis in TDateTime-Format??
For e.g.:
X-Axsis is a timeline between 0 sec. and 10 sec.!! When the timer is enabled then the colorline should be able to get its current position in TDateTime-Format...
When ColorLine stands on a position 3.2 sec then it should return the value 3.2 in TDateTime...
Or when the user drag the line to 6.7 sec then it should return 6.7...
Posted: Mon Nov 27, 2006 9:57 am
by narcis
Hi Thomas,
You can try with Delphi's
DateTimeToStr function:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := DateTimeToStr(Now);
end;
Posted: Tue Nov 28, 2006 2:18 pm
by 8577300
Hello Experts,
now my chart do this what I want!!
But one little question:
When the ColorLine changes its position every after 100msecs. then the line makes a flickering effect. I know the reason (clear and repainting of the line), but is there a possiblity to display the line without flickering when it changes its position??
Bye
Thomas
Posted: Tue Dec 05, 2006 12:24 pm
by Pep
Hi Thomas,
how about using :
ChartTool1.DragRepaint:=True;
This will make to change the colorline position directly where the mouse is over which improves the ficker of the line.