Margin with custom axis
Margin with custom axis
Hello,
Please find attached an example to understand my question
http://193.145.251.126/pnp/files/yxAwTREaT/labels.ten
If you open the chart editor and switch in the first serie the left axis of the serie between "Left" and "Custom 0" you can see with the left margin changes, and sometimes with "Custom 0" you cannot see the whole labels in the left axis. I have find the difference between left and custom 0 axis regarding to this margin but I didn't find it, how can I configurate my custom axis to have the same margin as "Left" axis?
Thanks in advance,
Please find attached an example to understand my question
http://193.145.251.126/pnp/files/yxAwTREaT/labels.ten
If you open the chart editor and switch in the first serie the left axis of the serie between "Left" and "Custom 0" you can see with the left margin changes, and sometimes with "Custom 0" you cannot see the whole labels in the left axis. I have find the difference between left and custom 0 axis regarding to this margin but I didn't find it, how can I configurate my custom axis to have the same margin as "Left" axis?
Thanks in advance,
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Margin with custom axis
This seems to work okay at runtime, e.g.wakeup wrote:I have find the difference between left and custom 0 axis regarding to this margin but I didn't find it, how can I configurate my custom axis to have the same margin as "Left" axis?
Code: Select all
private void InitializeChart()
{
tChart1.Import.Template.Load(@"C:\tmp\labels.ten");
tChart1[1].CustomVertAxis = null;
}
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 |
Re: Margin with custom axis
Yes but you are disabling the custom axis, I want to have the custom axis but having the same behaviour in the margin as the "Lef" axis.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Margin with custom axis
here is the code I'm using:wakeup wrote:Yes but you are disabling the custom axis, I want to have the custom axis but having the same behaviour in the margin as the "Lef" axis.
Code: Select all
private void InitializeChart()
{
tChart1.Import.Template.Load(@"C:\tmp\labels.ten"); //labels1.png
//tChart1.Panel.MarginLeft = 10; //uncomment for labels2.png
//tChart1[1].CustomVertAxis = null; //uncomment for labels3.png
}
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 |
Re: Margin with custom axis
I want to have the Label2.png result, but without changing the MarginLeft to 10. I mean, If I put the axis "Left" it is shown correctly with MarginLeft =3. Why with axis "Custom 0" it now shown in the same way with MarginLeft = 3?
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Margin with custom axis
This is because custom axes are behave differently to the default axes, and this difference is by design. Custom axes do not automatically resize the Chart rectangle, as default axes do, which means the margins have to be set manually.wakeup wrote:I want to have the Label2.png result, but without changing the MarginLeft to 10. I mean, If I put the axis "Left" it is shown correctly with MarginLeft =3. Why with axis "Custom 0" it now shown in the same way with MarginLeft = 3?
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 |
Re: Margin with custom axis
Why not? I think it would be logical to have the same behaviour...Christopher wrote:Custom axes do not automatically resize the Chart rectangle, as default axes do, which means the margins have to be set manually.
Do you have any code to set this margins automatically? I mean depending on the size of the chart and the lenght of the labels in the axis...
Thanks
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Margin with custom axis
Default axes position are known by the TeeChart code, that is why they are default. Knowing the position means that some calculations can be done to resize the chart rectangle. Custom axes positions are not known by the TeeChart code, they are set by the user. This means that calculations involving the resizing of the chart rectangle cannot be done automatically.wakeup wrote: Why not? I think it would be logical to have the same behaviour...
You could try something similar to this:wakeup wrote: Do you have any code to set this margins automatically? I mean depending on the size of the chart and the lenght of the labels in the axis...
Code: Select all
private void InitializeChart()
{
tChart1.Import.Template.Load(@"C:\tmp\labels.ten"); //labels1.png
tChart1.Draw();
double maxVal = tChart1[1].YValues.Maximum;
float width = tChart1.Graphics3D.TextWidth(maxVal.ToString(tChart1.Axes.Custom[0].Labels.ValueFormat));
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginLeft = Utils.Round(width * 1.1);
}
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 |
Re: Margin with custom axis
It doesn't run very well, is it possible to resize manually of the chart rectangle to get the same effect than automatically
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Margin with custom axis
In what sense does it not run very well? The code snippet runs as expected here.wakeup wrote:It doesn't run very well, is it possible to resize manually of the chart rectangle to get the same effect than automatically
And yes, you can manually resize the ChartRect with the following code:
Code: Select all
private void InitializeChart()
{
tChart1.Series.Add(typeof(Line)).FillSampleValues();
tChart1.Chart.CustomChartRect = true;
tChart1.Chart.ChartRect = Utils.FromLTRB(100, 100, 300, 300);
}
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 |