Page 1 of 1

Marks are cut off

Posted: Fri Jan 10, 2014 5:38 pm
by 10546565
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

Re: Marks are cut off

Posted: Mon Jan 13, 2014 4:21 pm
by yeray
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.

Re: Marks are cut off

Posted: Mon Jan 13, 2014 5:48 pm
by 10546565
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

Re: Marks are cut off

Posted: Mon Jan 13, 2014 5:49 pm
by 10546565
Attached is the demo.

Re: Marks are cut off

Posted: Wed Jan 15, 2014 6:24 pm
by 16565416
Any comments?

Re: Marks are cut off

Posted: Thu Jan 16, 2014 9:26 am
by yeray
Hello Ed,

We are investigating it. Please stay tuned.

Re: Marks are cut off

Posted: Thu Jan 16, 2014 12:04 pm
by yeray
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.