Page 1 of 1

Chart resizes when line is emphasized

Posted: Thu Mar 06, 2014 7:58 pm
by 16562566
In the line chart when the cursor hovers over a line, the width of the line is changed programmatically, to emphasize the line. In TeeChart 9.0.10 (2014 but also versions from 2013) this results in the chart being resized slightly, so the wider line fits. In older versions (8.0.6 definitely) this doesn't happen, and I would like to eliminate this behavior. I tried to change the situation by leaving margin space or playing around with minimums and maximums but so far only turning off Chart.Axes.<>.Automatic helped - but then the normal chart sizing when showing different content doesn't happen either.

Is there a way to turn this behavior off?
Attached is an example (I included the source code too below) that shows this behavior in the newer versions of TeeChart. Just click on the button to populate the cart, and then hover over the lines to see the jiggling:

---------------------

Code: Select all

unit TeeTest;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, VCLTee.TeEngine,
  Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Chart1: TChart;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure FillLineChart(ReloadDataOnly : Boolean);
    procedure LineSeriesMouseEnter(Sender: TObject);
    procedure LineSeriesMouseLeave(Sender: TObject);
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
 filllinechart(true);
end;

procedure TForm2.FillLineChart(ReloadDataOnly : Boolean);
var
  iRow, iCol : integer;
  pSeries :TLineSeries;
begin
    Chart1.Axes.Bottom.Title.Caption := ' ';
    for iRow := 0 to 6 do begin
      pSeries := TLineSeries.Create ( Chart1 );
      pSeries.LinePen.Width := 2;
      pSeries.ParentChart := Chart1;
      pSeries.Title := 'Series' + intToStr(iRow);
      pSeries.XValues.DateTime := FALSE;
      pSeries.OnMouseEnter := LineSeriesMouseEnter;
      pSeries.OnMouseLeave := LineSeriesMouseLeave;

      for iCol := 0 to 6 do
        pSeries.AddXY(iCol,icol + iRow, 'Point' + intToStr(iCol), clTeeColor);

    end;
end;

procedure Tform2.LineSeriesMouseEnter(Sender: TObject);
var
  ALineSeries : TLineSeries;
begin

  ALineSeries := TLineSeries(Sender);
  Chart1.Axes.Bottom.Title.Caption := ALineSeries.Title;
  ALineSeries.LinePen.Width := 8;
end;

procedure Tform2.LineSeriesMouseLeave(Sender: TObject);
var
  ALineSeries : TLineSeries;
begin
  ALineSeries := TLineSeries(Sender);
  Chart1.Axes.Bottom.Title.Caption := ' ';
  ALineSeries.LinePen.Width := 2;
end;


end.

Re: Chart resizes when line is emphasized

Posted: Fri Mar 07, 2014 3:34 pm
by yeray
Hello,
peldaul wrote:only turning off Chart.Axes.<>.Automatic helped - but then the normal chart sizing when showing different content doesn't happen either.
I tried this and it seems to work fine for me. I'm not sure to understand what's the problem with it:

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
begin
 filllinechart(true);
 Chart1.Draw;
 Chart1.Axes.Left.Automatic:=false;
 Chart1.Axes.Bottom.Automatic:=false;
end;

Re: Chart resizes when line is emphasized

Posted: Fri Mar 07, 2014 5:50 pm
by 16562566
Hello Yeray,

Thank you for looking into this. The problem is, that whenever I hover over a line, the whole chart resizes a bit. I would like the line to get emphasized, but not to have the chart resized at the same time. To better illustrate my point I uploaded an example (in Delphi 2007 using an older version of TeeChart) that works well (no resizing).

Re: Chart resizes when line is emphasized

Posted: Mon Mar 10, 2014 3:35 pm
by yeray
Hello,

I could reproduce the problem here thanks to the project you sent.
We're studying what's the best way to fix it. We'll be back to you asap.