Page 1 of 1

TLineSeries and TBarSeries with DataSource := ADOQuery

Posted: Thu Jan 24, 2008 4:11 pm
by 10547999
Hello,
is there any way to insert in a LineSeries a NullValue if the value of a BarSeries is null? Both used similar ADOQuery as Datasource and the xChartValues.ValueSource are identical for both series.

If the ValueSource aren't from a Datasource the code can look like:

For i:= 0 to Barseries. XValues.count -1 do
if Barseries.isnull(i) then LineSeries.setnull(i,true);

your sincerely

Willi Ebert

Posted: Fri Jan 25, 2008 1:53 pm
by 10547999
Hello,
my first try was:
procedure TEpiMonitorForm.Series2BeforeDrawValues(Sender: TObject);
var xmin,xmax,i,x : integer;
hoehe : double;
alabel : string;
begin
xmin := round (Series1.MinXValue) ;
xmax := round(Series1.MaxXValue );
for x := xmin to xmax do
begin
hoehe := 0;
alabel := inttostr(x);
for i := 0 to Series1.Count - 1 do
if round(Series1.XValue ) = x then
begin
hoehe := Series1.YValue ;
alabel := inttostr(x);
end;
if hoehe = 0 then
begin
Series1.AddNullXY(x,0,alabel);
Series2.AddNullXY(x,0,alabel);
end;
end;
end;

This adds the right NullValues to Series2, but Series2. count is now highter than Series1.count. Some points of series2 are now not painted

Series1 is a TBarSeries with x and no., Series2 is a TlineSeries with x and mean duration
Here are the data:
Text X no. X mean duration
-4 -4 1 -4 0
96 96 33 96 3.675757576
97 97 35 97 3.617142857
98 98 35 98 3.888571429
99 99 0 99 0
100 100 0 100 0
101 101 19 101 3.605263158
102 102 38 102 3.434210526

The points (99,0) (100,0) are added with Series2.AddNullXY(x,0,alabel). The old points (101,3.605263158) and (102,3.434210526) of Series2 are now not drawn after I had added two new points.

Can you help me?

your sincerely

Willi Ebert

Posted: Fri Jan 25, 2008 3:42 pm
by narcis
Hi Willi Ebert,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here? You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Fri Jan 25, 2008 4:20 pm
by 10547999
Hello,
i have uploaded a demo test.zip. Like in your demo the link to the file with the data is c:\test2.txt. We use Delphi 7 sp1 with TeeChart Pro V8. If the routine added the new points in Series2.BeforeDrawValues the error exists (three ponts of series1 are not drawn). If the points are added manually with Button1Click series1 is ok.

your sincerely

Willi Ebert

Posted: Wed Jan 30, 2008 12:27 pm
by Pep
Hi Willi,

as you're using the AddNullXY method, the correct way would be to do it after the points has been added (for example into the OnAfterDraw event), instead of the OnBeforeDrawSeries event.

It works fine with :

Code: Select all

procedure TForm1.Chart2AfterDraw(Sender: TObject);
var xmin,xmax,i,x : integer;
hoehe : double;
alabel : string;
begin
xmin := round (Series1.MinXValue) ;
xmax := round(Series1.MaxXValue );
for x := xmin to xmax do
begin
hoehe := 0;
alabel := inttostr(x);
for i := 0 to Series1.Count - 1 do
if round(Series1.XValue [i]) = x then
begin
hoehe := Series1.YValue [i];
alabel := inttostr(x);
end;
if hoehe = 0 then
begin
Series1.AddNullXY(x,0,alabel);
Series2.AddNullXY(x,0,alabel);
end;
end;
end;
In case you want to use the OnBeforeDrawEvent, you could se the point as null by using the SetNull method :

Code: Select all

procedure TForm1.Series2BeforeDrawValues(Sender: TObject);
var xmin,xmax,i,x : integer;
hoehe : double;
alabel : string;
begin
xmin := round (Series1.MinXValue) ;
xmax := round(Series1.MaxXValue );
for x := xmin to xmax do
begin
hoehe := 0;
alabel := inttostr(x);
for i := 0 to Series1.Count - 1 do
if round(Series1.XValue [i]) = x then
begin
hoehe := Series1.YValue [i];
alabel := inttostr(x);
end;
if hoehe = 0 then
begin
Series1.setnull(x,true);
Series2.setnull(x,true);
end;
end;
end;

Posted: Wed Jan 30, 2008 2:22 pm
by 10547999
Hello,
thanks for your help. Meanwhile I moved the code to add the null values on the end of routine witch opened the ADOQuery. This worked also.

your sincerely

Willi Ebert