Page 1 of 1
A way to know if the chart is too small to display correctly
Posted: Mon Feb 06, 2017 2:15 pm
by 15048900
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 (32.9 KiB) Viewed 8962 times
But the user resizes the chart until the chart cannot be displayed:
- resize until no thickness.PNG (21.69 KiB) Viewed 8961 times
Or even worse until things start overlapping:
- Way too small.PNG (19.76 KiB) Viewed 8957 times
So is there any way to know if the chart and legend are overlapping or if the chart cannot be drawn any smaller?
Re: A way to know if the chart is too small to display correctly
Posted: Tue Feb 07, 2017 3:01 pm
by Christopher
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.
Re: A way to know if the chart is too small to display correctly
Posted: Tue Feb 14, 2017 8:20 pm
by 15048900
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
Re: A way to know if the chart is too small to display correctly
Posted: Wed Feb 15, 2017 10:43 am
by Christopher
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;
}
}