Page 1 of 1

Replacement for FillSequence after deleting data ?

Posted: Thu Feb 21, 2008 12:41 pm
by 9349911
Hi !

I use this code to delete data from a chart:

Code: Select all

    // Daten löschen
    if Tool <> NIL then begin
      for i := Form1.MainChart[0].Count-1 downto 0 do
      begin
        tmp := Form1.MainChart[0].XValue[i];

        if ((tmp >= Tool.StartValue) and (tmp <= Tool.EndValue)) then
        begin
          for j := 0 to Form1.MainChart.SeriesCount - 1 do
            if Form1.MainChart[j].Count > 0 then
              Form1.MainChart[j].Delete(i);
        end;
      end;
   {   for j := 0 to Form1.MainChart.SeriesCount - 1 do
        Form1.MainChart[j].XValues.FillSequence;    }
    end;
It uses a TColorBandTool for selecting the area which will be deleted. This works nearly perfect, but I´m in big trouble with FillSequence.

We often have x values for the series which are in double format. So the increment from x value to the next x value is not 1.

If I run FillSequence it sets all X values to integer values with the increment of 1. This ends up in a wrong display for the x axis. The values are no longer correct.

So is there a FillSequence replacement which won´t destroy the X axis values?

Let me show you a simple example what I expect:
This should be my original x Axis vaules:

Code: Select all

0  0,5  1  1,5  2  2,5  3  3,5  4
Now I set my TColorBandTool and delete all values from 2 to 3.

The result after this step:

Code: Select all

0  0,5  1  1,5   3,5  4
What I need is this (the function should recalculate the values after 3):

Code: Select all

0  0,5  1  1,5   2   2,5
But FillSequence does this:

Code: Select all

0  1  2  3   4  5
Can you give me an example how I can realize this?

Posted: Thu Feb 21, 2008 2:27 pm
by narcis
Hi Dominik,

The only way I can think of to achieve what you request is implementing your custom FillSequence method doing something like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  CustomFillSequence(Series1, 0.5);
end;

procedure TForm1.CustomFillSequence(Series: TChartSeries;
  Increment: double);
var i: Integer;
begin
  for i:=0 to Series.Count-1 do
    Series.XValue[i] := i*Increment;
end;

Posted: Fri Feb 22, 2008 10:20 am
by 9349911
Hi Narcis,

as usual ... works perfect. Thx alot !! :D