[Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Miguel A. Risco

Hi All, I found a possible Bug in TAChart component. Lazarus v0.9.30.1  SVN:3056 on Windows 7 x64

 

Create a Project with a TChart and TButton controls, add a TLineseries and TUserDefinedChartSource with some points, select the last one as source for the serie. Define a Var array of real and assign values to the array on the Tbutton onclick event. Populate the AItem values with the data in the array. Sometimes when I zoom the chart the serie is not redrawing. (The example project is not attached because size limit of the message). Make a zoom on the second point [0.1,0.5] but without include the zero Y axis value, the serie is not drawing but if the zero level is included in the zoom then the serie is drawing correctly)

 

  TForm1 = class(TForm)

    Button1: TButton;

    Chart1: TChart;

    Chart1LineSeries1: TLineSeries;

    DataSource: TUserDefinedChartSource;

    procedure Button1Click(Sender: TObject);

    procedure DataSourceGetChartDataItem(ASource: TUserDefinedChartSource;

      AIndex: Integer; var AItem: TChartDataItem);

  end;

 

var

  Form1: TForm1;

  dat:array [0..3] of real;

 

implementation

 

{$R *.lfm}

 

{ TForm1 }

 

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  DataSource.BeginUpdate;

  dat[0]:=0;

  dat[1]:=0.5;

  dat[2]:=0;

  dat[3]:=-0.5;

  DataSource.EndUpdate;

end;

 

procedure TForm1.DataSourceGetChartDataItem(ASource: TUserDefinedChartSource;

  AIndex: Integer; var AItem: TChartDataItem);

begin

  AItem.X:=AIndex/10;

  AItem.Y:=dat[AIndex];

end;

 

Thank you.

    

 


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Alexander Klenin
2011/4/19 Miguel A. Risco <[hidden email]>:

> Hi All, I found a possible Bug in TAChart component. Lazarus v0.9.30.1
>  SVN:3056 on Windows 7 x64
>
> Create a Project with a TChart and TButton controls, add a TLineseries and
> TUserDefinedChartSource with some points, select the last one as source for
> the serie. Define a Var array of real and assign values to the array on the
> Tbutton onclick event. Populate the AItem values with the data in the array.
> Sometimes when I zoom the chart the serie is not redrawing. (The example
> project is not attached because size limit of the message). Make a zoom on
> the second point [0.1,0.5] but without include the zero Y axis value, the
> serie is not drawing but if the zero level is included in the zoom then the
> serie is drawing correctly)
I can not reproduce on WindowsXP with Lazarus trunk.
I am not sure what problem did you have with the attachment -- it should be
very small. I have created an example project for you -- do you see
the issue with it?

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

userdefseries_zoom_test.7z (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Miguel A. Risco
Hi Alexander, your Project is ok, but if your put a tbutton and fill the array on the Onclick event and not in the constructor of the form then the series is not drawing after the zoom on the second point. If I comment the line " if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;" in the TASeries.pas unit then the series is drawing properly.

Best regards

Miguel.

-----Mensaje original-----
De: Alexander Klenin [mailto:[hidden email]]
Enviado el: martes, 19 de abril de 2011 01:14 a.m.
Para: Lazarus mailing list
Asunto: Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

2011/4/19 Miguel A. Risco <[hidden email]>:

> Hi All, I found a possible Bug in TAChart component. Lazarus v0.9.30.1
>  SVN:3056 on Windows 7 x64
>
> Create a Project with a TChart and TButton controls, add a TLineseries
> and TUserDefinedChartSource with some points, select the last one as
> source for the serie. Define a Var array of real and assign values to
> the array on the Tbutton onclick event. Populate the AItem values with the data in the array.
> Sometimes when I zoom the chart the serie is not redrawing. (The
> example project is not attached because size limit of the message).
> Make a zoom on the second point [0.1,0.5] but without include the zero
> Y axis value, the serie is not drawing but if the zero level is
> included in the zoom then the serie is drawing correctly)

I can not reproduce on WindowsXP with Lazarus trunk.
I am not sure what problem did you have with the attachment -- it should be very small. I have created an example project for you -- do you see the issue with it?

--
Alexander S. Klenin


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Alexander Klenin
On Tue, Apr 19, 2011 at 17:46, Miguel A. Risco <[hidden email]> wrote:
> Hi Alexander, your Project is ok, but if your put a tbutton and fill the array on the Onclick event and not in the constructor of the form then the series is not drawing after the zoom on the second point. If I comment the line " if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;" in the TASeries.pas unit then the series is drawing properly.

Ah, I see now.
You need to call ds.Reset before ds.EndUpdate.
Maybe Reset should be called automatically by EndUpdate...

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Miguel A. Risco
Calling ds.Reset make the fix. I also think that Reset could be called by
EndUpdate.

Thank you

Miguel

-----Mensaje original-----
De: Alexander Klenin [mailto:[hidden email]]
Enviado el: martes, 19 de abril de 2011 02:04 a.m.
Para: Lazarus mailing list
Asunto: Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart
Source not are redrawing properly

On Tue, Apr 19, 2011 at 17:46, Miguel A. Risco <[hidden email]> wrote:
> Hi Alexander, your Project is ok, but if your put a tbutton and fill the
array on the Onclick event and not in the constructor of the form then the
series is not drawing after the zoom on the second point. If I comment the
line " if not RectIntersectsRect(ext, ParentChart.CurrentExtent) then exit;"
in the TASeries.pas unit then the series is drawing properly.

Ah, I see now.
You need to call ds.Reset before ds.EndUpdate.
Maybe Reset should be called automatically by EndUpdate...

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] TAChart possible Bug: Series with UserDefinedChart Source not are redrawing properly

Alexander Klenin
On Tue, Apr 19, 2011 at 18:15, Miguel A. Risco <[hidden email]> wrote:
> Calling ds.Reset make the fix. I also think that Reset could be called by
> EndUpdate.

Done in r30379

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus