Chart Title Centering

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 62
Joined: Wed Sep 07, 2011 12:00 am

Chart Title Centering

Post by lilo » Tue Nov 22, 2011 7:28 am

If I set TChart1.Header.Alignment=Alignment.Center, the title plots in the center of the teechart, but not centered between the x axis? See picture. The title position does not take into account the left margin of the chart, so the title is skewed to the left. This seems to be a bad bug to me. Why can't the title plot centered between the bottom axis ?
ContTest2.jpg
ContTest2.jpg (115.26 KiB) Viewed 5178 times

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Chart Title Centering

Post by Narcís » Tue Nov 22, 2011 11:47 am

Hi lilo,

Ok, I'll add your request to the wish-list (TV52015911) to be considered for inclusion in future releases. In the meantime you can manually center the title like this:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }   

    private void InitializeChart()
    {
      tChart1.Series.Add(new Steema.TeeChart.Styles.Bar()).FillSampleValues();
      tChart1.Header.CustomPosition = true;
      tChart1.Panel.MarginTop = 15;
      this.tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
      tChart1.Draw();
    }

    void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      SizeF size = g.MeasureString(tChart1.Header.Font, tChart1.Header.Text);
      int length = tChart1.Axes.Bottom.IEndPos - tChart1.Axes.Bottom.IStartPos;
      int x = tChart1.Axes.Bottom.IStartPos + (length / 2) - (int)(size.Width / 2);
      tChart1.Header.Left = x;
      tChart1.Header.Top = 10;
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply