Page 1 of 1

Top Axis with Gant graphic

Posted: Mon Jan 11, 2016 8:42 am
by 16555944
Hello

I have attached a PDF, that shows the acutal print out of my gant graphic.

The bottom axis shows the date of the gant data. I try to show also the top axis with the week number of the year, assigned to the gant data. But i don't have any idea where i have to start with programming.

Also does i have the problem, that the text are not realy clear (pixels) at the print out and the allignment are should be left!

May somebody have my a hint.

Thanks
Gregor

Re: Top Axis with Gant graphic

Posted: Tue Jan 12, 2016 9:37 am
by yeray
Hi Gregor,
viper wrote:The bottom axis shows the date of the gant data. I try to show also the top axis with the week number of the year, assigned to the gant data. But i don't have any idea where i have to start with programming.
You should assign both axes to your series to make them visible.

Code: Select all

Series1.HorizAxis:=aBothHorizAxis;
Since there's no formatdatetime to show the week number of the year, you should use OnGetAxisLabel event to format the string manually. Ie:

Code: Select all

uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.HorizAxis:=aBothHorizAxis;

  Chart1.Axes.Top.Increment:=DateTimeStep[dtOneWeek];
  Chart1.OnGetAxisLabel:=Chart1GetAxisLabel;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
  ValueIndex: Integer; var LabelText: string);
var tmpDate: TDateTime;
begin
  if (Sender = Chart1.Axes.Top) and (LabelText<>'') then
  begin
    tmpDate:=StrToDateTime(LabelText);
    LabelText:=IntToStr(WeekOf(tmpDate));
  end;
end;
viper wrote:Also does i have the problem, that the text are not realy clear (pixels) at the print out and the allignment are should be left!
We should differentiate:

- Printing resolution. Take a look at the printing better article here.

- Alignment. I'm not sure to understand what doesn't look as you'd expect. Could you please expand? Note an sscce helps to easily understand and reproduce the problems.

Re: Top Axis with Gant graphic

Posted: Wed Jan 13, 2016 7:35 am
by 16555944
Hello Yeray

Thank you for your fast respons and answer. I could solve my problem with the calendar number and printout resolution.

Now it just left the problem with the alligment of the text (Gant) at the left side.

When you take a look at my printout example, the text for the gant are center alligned. But i try to allign it left, but i can't find the responsible property.

Best Regards
Gregor

Re: Top Axis with Gant graphic

Posted: Wed Jan 13, 2016 10:08 am
by yeray
Hi Gregor,
viper wrote:Thank you for your fast respons and answer. I could solve my problem with the calendar number and printout resolution.
I'm glad to hear you found how to make it work as you wish.
viper wrote:Now it just left the problem with the alligment of the text (Gant) at the left side.

When you take a look at my printout example, the text for the gant are center alligned. But i try to allign it left, but i can't find the responsible property.
Try with this:

Code: Select all

Chart1.Axes.Left.Items.Format.TextAlignment:=taLeftJustify;

Re: Top Axis with Gant graphic

Posted: Wed Jan 13, 2016 2:42 pm
by 16555944
Hello Yeray

Thanks, you Tip works perfect.

Gregor