Page 1 of 1

IncludeNulls

Posted: Wed Nov 19, 2008 4:33 pm
by 10050873
Hello,

I create a lineSeries for average function like it.

Code: Select all

   SerieMoy:=TLineSeries.Create(self);
   ChrtGraphDispo.AddSeries(SerieMoy);
   SerieMoy.SetFunction(TAverageTeeFunction.Create(Self));
Howerver i don't find which property where i can assign IncludeNulls to false?

Thank you

Regards

Posted: Wed Nov 19, 2008 4:52 pm
by narcis
Hi Calou,

You have 2 options here:

1. Typecast your series function like this:

Code: Select all

  (SerieMoy.FunctionType as TAverageTeeFunction).IncludeNulls:=false;
2. Create a variable for the average function too:

Code: Select all

  MyAverage:=TAverageTeeFunction.Create(Self);
  MyAverage.IncludeNulls:=false;
  SerieMoy.SetFunction(MyAverage);

Posted: Wed Nov 19, 2008 5:11 pm
by 10050873
Thank you for your answer.

It seems that in my case it doesn't work.

This is my code :

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  i: Integer;

begin

  for i := 0 to High(BarGraphDispo) do
  begin
    BarGraphDispo[i]:=TBarSeries.Create(self);
    BarGraphDispo[i].ParentChart:=ChrtGraphDispo;
    BarGraphDispo[i].Marks.Style:=smsValue;
    BarGraphDispo[i].Marks.Visible:=TRUE;
    //BarGraphDispo[i].SideMargins:=true;


    //BarGraphDispo[i].Color:=TabColor[i];
    BarGraphDispo[i].Title:='Dispo '+IntToStr(i);
    //Définition du gradient
    BarGraphDispo[i].BarStyle:=bsRectGradient;
    BarGraphDispo[i].Gradient.StartColor:=clYellow;
    BarGraphDispo[i].Gradient.Direction:=gdTopBottom;

    BarGraphDispo[i].BarWidthPercent:=70;
    BarGraphDispo[i].MultiBar:=mbSide;

    BarGraphDispo[i].ValueFormat:='# ##0.#';
  end;

   
  ChrtGraphDispo.Axes.Left.Automatic:=FALSE;
  ChrtGraphDispo.Axes.Left.AutomaticMaximum:=FALSE;
  //Affiche l'echelle en %
  ChrtGraphDispo.Axes.Left.AxisValuesFormat:='0.###%';
  ChrtGraphDispo.Axes.Left.Increment:=10;
  ChrtGraphDispo.Axes.Left.Maximum:=100;
  ChrtGraphDispo.Axes.Left.Minimum:=0;

  ChrtGraphDispo.Axes.Bottom.Increment:=0;

  //ChrtGraphDispo.Axes.Bottom.Maximum:=4;
  //ChrtGraphDispo.Axes.Bottom.Minimum:=0;
  //Pour que tous les histos par projet soient collés
  BarGraphDispo[0].MultiBar:=mbSide;
    SerieMoy:=TLineSeries.Create(self);
 ChrtGraphDispo.AddSeries(SerieMoy);
 SerieMoy.Color:=clPurple;
  SerieMoy.Title:='MOYENNE';
  SerieMoy.SetFunction(TAverageTeeFunction.Create(Self));


  //(SerieMoy.FunctionType as TAverageTeeFunction).IncludeNulls:=FALSE;
  SerieMoy.DataSources.Clear;
  SerieMoy.Marks.Show;
  SerieMoy.Marks.Style:=smsValue;
  SerieMoy.DataSources.Add(BarGraphDispo[0]);
  SerieMoy.DataSources.Add(BarGraphDispo[1]);
  SerieMoy.DataSources.Add(BarGraphDispo[2]);
  SerieMoy.FunctionType.Period:=1;



end;

procedure TForm1.Button3Click(Sender: TObject);
var
  i: Integer;
  teefnct:TAverageTeeFunction;  
begin
  Button1Click(self);

    BarGraphDispo[0].AddXY(1,50,'Projet 1',TabColor[0]);
    BarGraphDispo[0].AddXY(2,90,'Projet 2',TabColor[0]);
    BarGraphDispo[0].AddNullXY(3,95,'Projet 3');
    BarGraphDispo[1].AddXY(1,50,'Projet 1',TabColor[1]);
    BarGraphDispo[1].AddXY(2,60,'Projet 2',TabColor[1]);
    BarGraphDispo[1].AddXY(3,65,'Projet 3',TabColor[1]);
    BarGraphDispo[2].AddXY(1,70,'Projet 1',TabColor[2]);
    BarGraphDispo[2].AddNullXY(2,0,'Projet 2');
    BarGraphDispo[2].AddXY(3,70,'Projet 3',TabColor[2]);    

    //BarGraphDispo[2].AddXY(2,100.08965,'Projet 2',TabColor[2]);
    teefnct:=TAverageTeeFunction.Create(Self);
    teefnct.IncludeNulls:=false;
    SerieMoy.SetFunction(teefnct);
    SerieMoy.FunctionType.ReCalculate; 
end;

The average is calculated with the null values

Regards

Posted: Thu Nov 20, 2008 9:34 am
by 10050873
up :oops:

Posted: Thu Nov 20, 2008 9:39 am
by narcis
Hi Calou,

We could reproduce the issue and are investigating it. We will get back to you ASAP.

Posted: Wed Nov 26, 2008 2:47 pm
by narcis
Hi Calou,

We found out this is a bug that I have added to the list (TV52013612) to be fixed for next releases. In the meantime a workaround is this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
 SerieMoy: TLineSeries;
begin
  SerieMoy:=TLineSeries.Create(self);
   ChrtGraphDispo.AddSeries(SerieMoy);
  SerieMoy.SetFunction(TAverageTeeFunction.Create(Self));


  //(SerieMoy.FunctionType as TAverageTeeFunction).IncludeNulls:=FALSE;
  SerieMoy.DataSources.Clear;
  SerieMoy.Marks.Show;
  SerieMoy.Marks.Style:=smsValue;
  SerieMoy.DataSources.Add(BarGraphDispo[0]);
  SerieMoy.DataSources.Add(BarGraphDispo[1]);
  SerieMoy.DataSources.Add(BarGraphDispo[2]);
  SerieMoy.FunctionType.Period:=1;

    BarGraphDispo[0].AddXY(1,50,'Projet 1',clTeecolor);
    BarGraphDispo[0].AddXY(2,90,'Projet 2',clTeecolor);
    BarGraphDispo[0].AddNullXY(3,95,'Projet 3');
    BarGraphDispo[1].AddXY(1,50,'Projet 1',clTeecolor);
    BarGraphDispo[1].AddXY(2,60,'Projet 2',clTeecolor);
    BarGraphDispo[1].AddXY(3,65,'Projet 3',clTeecolor);
//    BarGraphDispo[1].AddNullXY(3,0,'Projet 4');
    BarGraphDispo[2].AddXY(1,70,'Projet 1',clTeecolor);
    BarGraphDispo[2].AddNullXY(2,0,'Projet 2');
    BarGraphDispo[2].AddXY(3,70,'Projet 3',clTeecolor);

    BarGraphDispo[0].Marks.Style:=smsValue;
    BarGraphDispo[1].Marks.Style:=smsValue;
    BarGraphDispo[2].Marks.Style:=smsValue;

    //BarGraphDispo[2].AddXY(2,100.08965,'Projet 2',TabColor[2]);
    teefnct:=TAverageTeeFunction.Create(Self);
    SerieMoy.SetFunction(teefnct);
    teefnct.IncludeNulls:=false;
    SerieMoy.FunctionType.ReCalculate;



  SerieMoy.DataSources.Delete(1);
  SerieMoy.DataSources.Add(BarGraphDispo[1]);
  SerieMoy.CheckDataSource;


end;

You need to remove one of the datasource series (better removing second one) and add it to the datasource list later. This makes IncludeNulls work fine.