A way to know if the chart is too small to display correctly

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

A way to know if the chart is too small to display correctly

Post by biqpaulson » Mon Feb 06, 2017 2:15 pm

We would like to know if there is a way to know if the chart has been resized to a point where the chart cannot be displayed correctly.

As an example this might be a chart where the user can see all of the bars:
Original everything okay.PNG
Original everything okay.PNG (32.9 KiB) Viewed 8959 times
But the user resizes the chart until the chart cannot be displayed:
resize until no thickness.PNG
resize until no thickness.PNG (21.69 KiB) Viewed 8958 times
Or even worse until things start overlapping:
Way too small.PNG
Way too small.PNG (19.76 KiB) Viewed 8954 times
So is there any way to know if the chart and legend are overlapping or if the chart cannot be drawn any smaller?

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: A way to know if the chart is too small to display correctly

Post by Christopher » Tue Feb 07, 2017 3:01 pm

Hello,

Yes, you should be able to use the GetAxesChartRect event, e.g.

Code: Select all

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = true;
      tChart1.Aspect.Orthogonal = false;
      tChart1.Aspect.Chart3DPercent = 40;
      tChart1.Series.Add(typeof(Tower)).FillSampleValues();

      tChart1.GetAxesChartRect += TChart1_GetAxesChartRect;
    }

    private void TChart1_GetAxesChartRect(object sender, GetAxesChartRectEventArgs e)
    {
      Rectangle rect = e.AxesChartRect;

      if(rect.Width < 50)
      {
        MessageBox.Show("Less than 50");
        rect.Width = 50;
        e.AxesChartRect = rect;
      }
    }
This will limit the width and advise of the same, and the same technique could be used for other ways to control Chart rendering.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

biqpaulson
Newbie
Newbie
Posts: 93
Joined: Thu Apr 17, 2008 12:00 am

Re: A way to know if the chart is too small to display correctly

Post by biqpaulson » Tue Feb 14, 2017 8:20 pm

Hello:

We are using the latest version of the product -- we will try out your suggestion and get back to you if we have issues.

As a related follow up question: Is there a way to tell if the legend doesn't fit? If we could detect that we could add the "legend scroll bar tool" automatically, unless there's a way to tell you to do that for us?

Thanks

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: A way to know if the chart is too small to display correctly

Post by Christopher » Wed Feb 15, 2017 10:43 am

Hello,
biqpaulson wrote: As a related follow up question: Is there a way to tell if the legend doesn't fit? If we could detect that we could add the "legend scroll bar tool" automatically, unless there's a way to tell you to do that for us?
Yes, you could use code similar to this:

Code: Select all

    private void InitializeChart()
    {
      Line series = new Line(tChart1.Chart);
      series.FillSampleValues(40);

      tChart1.BeforeDraw += TChart1_BeforeDraw;
    }

    LegendScrollBar scrollBar = new LegendScrollBar();

    private void TChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      ChartFont oldFont = g.Font;
      g.Font = tChart1.Legend.Font;
      int height = g.FontHeight;
      g.Font = oldFont;

      height += tChart1.Legend.VertSpacing;
      height *= tChart1[0].Count;

      if(tChart1.Chart.ChartBounds.Height < height)
      {
        scrollBar.Chart = g.Chart;
      }
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply