Marks are cut off

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Marks are cut off

Post by TestAlways » Fri Jan 10, 2014 5:38 pm

I use marks in a bar chart that can be clipped by the margin--for example, see the right-most bar in the chart below.

Image

Most of the time this does not happen. But for this scenario (and others) it does.

Is there a way of fixing this so that

(1) marks are not clipped; and

(2) it doesn't create needless margin for the charts that do not have the marks clipped?

Thank you,

Ed Dressel

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Marks are cut off

Post by Yeray » Mon Jan 13, 2014 4:21 pm

Hi Ed,

I can't reproduce this in a new chart with just a Bar series and some random values. I'm not sure about what element or combination of elements could be causing this. However, you probably can fix it adding some extra margin on the top of the chart, have you tried it?
Could you please send us some project we can run as-is to reproduce the problem here?
Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Marks are cut off

Post by TestAlways » Mon Jan 13, 2014 5:48 pm

See the attached demo. Click on any of the "test..." buttons at the bottom of the screen--the problem is accentuated when a graphic (bitmap) of the chart is created (displayed to the right of the chart).

Also, can you clarify about adding extra margin at the top—I don’t want to create needless margin that waists space. Is there a way of knowing how much margin to add? An example?

Thank you,

Ed Dressel

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Marks are cut off

Post by TestAlways » Mon Jan 13, 2014 5:49 pm

Attached is the demo.
Attachments
Marks Cut Off.zip
(2.89 KiB) Downloaded 569 times

Test Always
Newbie
Newbie
Posts: 6
Joined: Thu Mar 14, 2013 12:00 am

Re: Marks are cut off

Post by Test Always » Wed Jan 15, 2014 6:24 pm

Any comments?

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Marks are cut off

Post by Yeray » Thu Jan 16, 2014 9:26 am

Hello Ed,

We are investigating it. Please stay tuned.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9544
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Marks are cut off

Post by Yeray » Thu Jan 16, 2014 12:04 pm

Hi Ed,

You could do something like this to calculate the Margins needed for the multiline labels in the bottom axis, and for the multiline marks in the series:

Code: Select all

procedure TForm1.RecalcMargins;
var i, maxHeight, tmpNum: Integer;
    tmpSize: TPoint;
begin
  chrtSavingsNeeded.Draw;

  with chrtSavingsNeeded.Axes.Bottom do
  if LabelsMultiLine then
  begin
    maxHeight:=0;
    for i:=0 to Pred(Items.Count) do
    begin
      tmpSize:=chrtSavingsNeeded.MultiLineTextSize(Items[i].Text, Items[i].Format.TextFormat, tmpNum);
      maxHeight:=Max(maxHeight, tmpSize.Y);
    end;
    chrtSavingsNeeded.MarginUnits:=muPixels;
    chrtSavingsNeeded.MarginBottom:=maxHeight;
  end
  else
  begin
    chrtSavingsNeeded.MarginUnits:=muPercent;
    chrtSavingsNeeded.MarginBottom:=4;
  end;

  chrtSavingsNeeded.Draw;
  if Series1.Count>0 then
  begin
    maxHeight:=Series1.Marks.Positions[0].LeftTop.Y;
    for i:=1 to Pred(Series1.Count) do
      maxHeight:=Min(maxHeight, Series1.Marks.Positions[i].LeftTop.Y);

    chrtSavingsNeeded.MarginUnits:=muPixels;
    chrtSavingsNeeded.MarginTop:=(chrtSavingsNeeded.ChartRect.Top-maxHeight);
  end
  else
  begin
    chrtSavingsNeeded.MarginUnits:=muPercent;
    chrtSavingsNeeded.MarginTop:=8;
  end;
end;
You could call this method in each button, after adding the values in the series.
However, the margins needed for the images are different. To fix this, you could create a temporal chart with the final size, calculate the margins for it as above, and export this temporal chart.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply