Page 1 of 1

TreatNulls during runtime

Posted: Thu Mar 11, 2010 12:42 pm
by 10048184
Dear All

I use following code to create a line out of a database @ runtime. Unfortunately the property of interest "TreatNulls " is not applied.
In the ChartEditor, the property is set to what's been coded, but the line itself is not *affected*!
-> (speak, the line is drawn in any case in "tnIgnore" mode )
I did try to place the TreatNull code-line at different places, but without success.

can you advise me what am I doing wrong or how it can be corrected?

Code: Select all

   fs := TFastLineSeries.Create(Self);
    with fs do
    begin
      ParentChart := ch;
      XValues.Order := loNone;
      XValues.DateTime:= True;
      TreatNulls  := tnSkip; // tnDontPaint, tnSkip, tnIgnore   <-- is not "accepted"
      AutoRepaint := False;
      LinePen.OwnerCriticalSection := nil;
      FastPen := True;
      Stairs  := True;
      Title   := 'Test';

      DataSource := PCmain.D_DATA;
      XValues.ValueSource:= 'COL_0';
      YValues.ValueSource:= 'COL_4';

      CheckDatasource;
      Repaint;
    end;
Regards
Daniele

Using TeeChart8.06Delphi2009

Re: TreatNulls during runtime

Posted: Thu Mar 11, 2010 2:45 pm
by yeray
Hi Daniele,

Adding your values from a database you still need to mark those which you want to be null looping into your data and using series' SetNull method or changing the point's color to clNone.

Re: TreatNulls during runtime

Posted: Thu Mar 11, 2010 3:11 pm
by 10048184
Hi Yeray,
Sorry, you misunderstand. I don't "want" any value to be Null, but it just happans that values in the database are missing altogether.
Fact is that if you use the ChartEditor and go to series -> Treat Nulls and set "Skip" then the line is displayed without a gap (ie. the gaps are bridged) - which is what I like. and which I should be able to achieve by code.

If you set "Ignore" then the missing values (nils) are treated as zero (- a mathematical no-go !! ;-).
The other - even more correct - behaviour is with "Don't paint", in that case the line is interrupted, but for my purpose less optimal.

I'd like to set "Skip" from the beginning (by the code), but when run, it does not display as "Sikp", but as "Ignore".

I tried to put the line "TreatNulls := tnSkip;" after CheckDatasource but to no avail.

regards
Daniele

Re: TreatNulls during runtime

Posted: Thu Mar 11, 2010 3:44 pm
by yeray
Hi Daniele,

Excuse me, it seems I didn't understand you well.
So setting treatnulls as tnSkip through the editor it works fine but not at runtime, right?
Here I've tried the following (your code with some data) and it seems to work fine here. Could you please try it in a new simple application and see if the problem persists for you?

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
var fs: TFastLineSeries;
begin
  Chart1.View3D:=false;

  fs := TFastLineSeries.Create(Self);
  with fs do
  begin
    ParentChart := chart1;
    XValues.Order := loNone;
    XValues.DateTime:= True;
    TreatNulls  := tnSkip; // tnDontPaint, tnSkip, tnIgnore   <-- is not "accepted"
    AutoRepaint := False;
    LinePen.OwnerCriticalSection := nil;
    FastPen := True;
    Stairs  := True;
    Title   := 'Test';

    Add(20);
    Add(0);
    Add(10);
    AddNull(5);
    Add(10);
    Add(5);
  end;
end;
If this works as expected, there should be some property in your project that we are missing. So, please try to arrange an as simple as possible project we can run as-is to reproduce the problem here and we will take a look a it.

Re: TreatNulls during runtime

Posted: Thu Mar 11, 2010 4:47 pm
by 10048184
Dear Yeray,

The problem persists with a newly created project with the code from you last post.
I upload the project.
Notice that the charteditor displays the correct setting as has been coded, but by selecting "don't paint" and re-selecting Skip, the line is displayed correctly.

regards
Daniele

Re: TreatNulls during runtime

Posted: Fri Mar 12, 2010 4:13 pm
by yeray
Hi Daniele,

I've seen that this was a bug identified on 13th November 2009 in TeeChart v8.06 (TV52014561). And I've also seen that this was fixed on 3rd February 2010 so it should be available with the next maintenance release.
Also note that setting IgnoreNulls:=False should work around this in 8.06.

Re: TreatNulls during runtime

Posted: Fri Mar 12, 2010 8:03 pm
by 10048184
Thank you Yeray,
appreciate your workaround

regards
daniele