Axis title being overwritten by axis labels
Axis title being overwritten by axis labels
The attached image shows the y-axis title being overwritten by the y-axis labels. When this chart was first drawn, the max value on the y-axis was only 3-digits. But the user can interact with the chart changing the range up to 1,00,000. As this happens, the space reserved for the y-axis labels is not increased and the new labels overlap the y-axis title. Is there some setting that will cause the axis layout to dynamically recalculate as the range is changed? If not, is there a method I can call to ask TeeChart to update the layout reflecting the new range?
- Attachments
-
- Image showing the problem with axis label placement
- Axis.png (173.08 KiB) Viewed 5782 times
Re: Axis title being overwritten by axis labels
Hello JCincotta,
I have made a simple code where you can use to positioning the title of axes correctly and prevent the overlap:
Could you tell us if previous code works in your end?
Thanks,
I have made a simple code where you can use to positioning the title of axes correctly and prevent the overlap:
Code: Select all
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Header.Visible = false;
tChart1.Legend.Alignment = LegendAlignments.Bottom;
Random rnd = new Random();
for (int i = 0; i < 3; i++)
{
new Steema.TeeChart.Styles.Line(tChart1.Chart);
for (int j = 0; j < 20; j++)
{
tChart1[i].Add(j, rnd.Next(5000000));
}
}
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Axes.Left.Title.Visible = true;
tChart1.Axes.Left.Title.Text = "Y values of Line Series";
tChart1.Axes.Left.Title.Angle = 90;
tChart1.Draw();
PlaceAxes(0, 0, 0, 0, 0);
tChart1.AfterDraw += new PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Graphics3D g)
{
PlaceAxes(0, 0, 0, 0, 0);
}
private void PlaceAxes(int nSeries, int NextXLeft, int NextXRight, int MargLeft, int MargRight)
{
const int extraPos = 12;
const int extraMargin = 50;
//Variable
int MaxLabelsWidth;
int lenghtTicks;
int extraSpaceBetweenTitleAndLabels;
MaxLabelsWidth = tChart1.Axes.Left.MaxLabelsWidth();
lenghtTicks = tChart1.Axes.Left.Ticks.Length;
extraSpaceBetweenTitleAndLabels = (tChart1.Axes.Left.Title.Width);//- tChart1.Axes.Custom[nSeries].MaxLabelsWidth());
if (tChart1.Axes.Left.Title.Visible)
{
tChart1.Axes.Left.RelativePosition = NextXLeft;
NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos);
MargLeft = MargLeft + extraMargin;
}
tChart1.Panel.MarginLeft = MargLeft;
}
Thanks,
Best Regards,
Sandra Pazos / 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 |
Re: Axis title being overwritten by axis labels
No, I'm afraid this doesn't help. In my graph, Panel.MarginLeft is always just 3.0 and setting it to a larger value just gives me wasted space along the left edge.
Fooling around with the many properties on the chart (thanks for those, btw!), I think I found my answer. I believe all that is necessary is:
Fooling around with the many properties on the chart (thanks for those, btw!), I think I found my answer. I believe all that is necessary is:
Code: Select all
tChart1.Axes.Left.FixedLabelSize = false;
Re: Axis title being overwritten by axis labels
Hello JCincotta,
Thanks for your information. I am glad you have found a good solution for you . On the other hand, if you have any problems please let me know.
Thanks,
Thanks for your information. I am glad you have found a good solution for you . On the other hand, if you have any problems please let me know.
Thanks,
Best Regards,
Sandra Pazos / 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 |