Page 1 of 1

TChart 2010 VCL - Bug in TColorLineTool

Posted: Wed May 19, 2010 2:17 am
by 16456147
I think I have run into a bug with the TColorLineTool when zooming and unzooming a chart. Here is some sample code that you can use to repro the bug. This was done using the new TChart 2010 VCL with Delphi 2007. Machine is running Windows Vista Ultimate, 32-bit, 4GB ram.

Code: Select all

procedure TForm6.FormCreate(Sender: TObject);
var i,j: Integer;
    tmpColorLine: TColorLineTool;
begin
  Chart1.AddSeries(TBarSeries.Create(Self));

  for i:=0 to 50 do
    Chart1[0].Add(10*i);

  tmpColorLine:=TColorLineTool.Create(Self);
  tmpColorLine.Axis:=Chart1.Axes.Left;
  tmpColorLine.Value:=100;
  tmpColorLine.Pen.Color:=clRed;
  tmpColorLine.Pen.Width:=2;
  Chart1.Tools.Add(tmpColorLine);

  tmpColorLine:=TColorLineTool.Create(Self);
  tmpColorLine.Axis:=Chart1.Axes.Left;
  tmpColorLine.Value:=200;
  tmpColorLine.Pen.Color:=clGreen;
  tmpColorLine.Pen.Width:=2;
  Chart1.Tools.Add(tmpColorLine);

  tmpColorLine:=TColorLineTool.Create(Self);
  tmpColorLine.Axis:=Chart1.Axes.Left;
  tmpColorLine.Value:=300;
  tmpColorLine.Pen.Color:=clBlue;
  tmpColorLine.Pen.Width:=2;
  Chart1.Tools.Add(tmpColorLine);

  tmpColorLine:=TColorLineTool.Create(Self);
  tmpColorLine.Axis:=Chart1.Axes.Left;
  tmpColorLine.Value:=400;
  tmpColorLine.Pen.Color:=clBlack;
  tmpColorLine.Pen.Width:=2;
  Chart1.Tools.Add(tmpColorLine);
end;
The sample will create a simple bar chart with 4 TColorLines with different colors. Zoom in and out several times and you will notice that some of the lines will start to disappear after zooming out even though they should be visible. If you look closer you will see that what is actually happening is the line's value is being changed and in fact the line is visible. It's just merged with another line because it's value is now the same as the other line. If you zoom in and out enough, eventually you will end up with a single line (actually all 4 lines having the same value).

Unless I'm mistaken, I don't think this should be happening. Please advise.

Thanks
Scott

Re: TChart 2010 VCL - Bug in TColorLineTool

Posted: Wed May 19, 2010 11:46 am
by yeray
Hi Scott,

You could try with:

Code: Select all

tmpColorLine.NoLimitDrag:=true;

Re: TChart 2010 VCL - Bug in TColorLineTool

Posted: Wed May 19, 2010 5:02 pm
by 16456147
Initial testing seems to show that adding "NoLimitDrag := True" prevents the problem from happening.

However, I still think that the line values should not be changing just because the chart was zoomed regardless of the NoLimitDrag setting. Can you confirm this is an issue?

Scott

Re: TChart 2010 VCL - Bug in TColorLineTool

Posted: Thu May 20, 2010 1:59 pm
by yeray
Hi Scott,

Well, it is a known issue recently discussed in the NET forums as you'll see here.
I've added to the ticket number [TF02014836] that VCL behaves in the same way so the enhancement would be implemented in both versions.

Re: TChart 2010 VCL - Bug in TColorLineTool

Posted: Thu May 20, 2010 7:09 pm
by 16456147
Cool. Thanks!

Scott