Page 1 of 1
cant see last label on bottom axis
Posted: Mon Mar 14, 2011 3:35 pm
by 14045267
In this small demo I try to create a chart with three labels
the last one is not visible .
I only see 2 labels on the x axis label1 and label 2.
this.tChart1.Aspect.View3D = false;
this.tChart1.Axes.Bottom.MinorTicks.Visible = false;
tChart1.Legend.Alignment = LegendAlignments.Bottom;
Series s1 = new Line();
tChart1.Series.Add(s1);
s1.Title = "Series1";
Line s2= new Line();
s2.Title = "Series 2";
tChart1.Series.Add(s2);
for (int i = 0; i < 3;i++ )
{
s2.Add(i * 10, "label" + i.ToString());
s1.Add(i * 20, "label" + i.ToString());
}
any idea why
Thanks.
Also , I noticed that in 3D if the last label name is long then it is cut on the right side.
Actually our problem in our application is that we do have 2D chart with 2 labels , one at x = 0 and one at the end of the x axis , we do see both of them but the second one is cut .
I tried to reproduce this in a standalone application (see above ) but for some reason in 2D I dont even get the last label.
Re: cant see last label on bottom axis
Posted: Tue Mar 15, 2011 12:11 pm
by 10050769
Hello rino,
I couldn't reproduce your problem using last maintenance release and your example code, and all labels appears in my chart as you can see in next image:
- Chart1.jpg (43.37 KiB) Viewed 11454 times
Could you tell us which version of TeeChart are you using?
Re: cant see last label on bottom axis
Posted: Tue Mar 15, 2011 1:40 pm
by 14045267
Hi Sandra
Im using version 4.0.2011.2082
But actually , the defect I have in our real application is that the last label is visible but cut at the right side.
in your demo , if you try and make the last label , something longer , for example " very long label 2" , you will see that it will be cut.
This is the defect I am trying to fix.
Re: cant see last label on bottom axis
Posted: Tue Mar 15, 2011 1:54 pm
by 14045267
Hi Sandra
I just did a test and noticed that the last label can disappear and appear and it depending on the size of the chart.
I docked the chart in a window and I played with the size of the window.
Sometimes the last label disappears and then it reappears. so its just a matter of what size the chart actually is .
In anycase , when it does appear the last label is cut to the right if its not short ("long label 3") for example.
SO there are two seperate issues.
1. The last label doesnt always show (depends on the exact size , its nothing to do with a minimum size , I can make a window smaller and it can disapppear and suddenly appear a gain during the shrinking)
2. The last label is cut if its long.
Re: cant see last label on bottom axis
Posted: Wed Mar 16, 2011 12:45 pm
by 10050769
Hello rino,
1. The last label doesnt always show (depends on the exact size , its nothing to do with a minimum size , I can make a window smaller and it can disapppear and suddenly appear a gain during the shrinking)
I have modified your code:
Code: Select all
Steema.TeeChart.Styles.Line series1,series2;
private void InitializeChart()
{
//Chart
tChart1.Dock = DockStyle.Fill;
this.tChart1.Aspect.View3D = false;
this.tChart1.Axes.Bottom.MinorTicks.Visible = false;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
//Series
series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
series2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1.Panel.MarginRight = 10;
series1.Title = "Series1";
series2.Title = "Series2";
for (int i = 0; i < 3; i++)
{
series1.Add(i * 10, "long label 3" + i.ToString());
series2.Add(i * 20, "long label 3" + i.ToString());
}
}
and I have gotten next image:
- Chart1Label.jpg (18.18 KiB) Viewed 11338 times
Could you tell us if your problem appears in previous image? If your problem is it I suggest you change the label angle as do in below lines:
Code: Select all
tChart1.Axes.Bottom.Labels.Angle = 90;
2. The last label is cut if its long.
You can try to increase Margin Right of Chart as do in next line of code:
I hope will helps.
Thanks,
Re: cant see last label on bottom axis
Posted: Thu Mar 17, 2011 12:14 pm
by 14045267
Hi Sandra
I cannot make the angle 90 , becuase we want the graph to remain the same hieght
regarding the margin , the problem is I dont know in advance what the label name will be so I need to resize the margin dynamically , which I am not sure how to do so I can I know how much margin to give.
Dont you consider this a bug ? because I would expect the label to shift to the left if it doesnt fit in .
Thanks
Re: cant see last label on bottom axis
Posted: Thu Mar 17, 2011 3:23 pm
by 10050769
Hello rino,
I have added your request in wish-list with number[
TF02015450] to be considered inclusion it in next maintenance releases of TeeChart.Net.On the other hand, I have made a simple code that you can use as workaround:
Code: Select all
Steema.TeeChart.Styles.Line series1, series2;
private void InitializeChart()
{
//Chart
tChart1.Dock = DockStyle.Fill;
this.tChart1.Aspect.View3D = false;
this.tChart1.Axes.Bottom.MinorTicks.Visible = false;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
//Series
series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
series2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
//tChart1.Panel.MarginRight = 10;
series1.Title = "Series1";
series2.Title = "Series2";
for (int i = 0; i < 3; i++)
{
series1.Add(i * 10, "long label 3" + i.ToString());
series2.Add(i * 20, "long label 3" + i.ToString());
}
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if (series1.Labels[tChart1.Series.Count-1].Length/2 >=tChart1.Panel.MarginRight|| series2.Labels[tChart1.Series.Count-1].Length/2>=tChart1.Panel.MarginRight)
{
tChart1.Panel.MarginRight = series1.Labels[tChart1.Series.Count-1].Length / 2 + tChart1.Panel.MarginRight;
}
}
Could you tell us, if previous code works as you expected?
I hope will helps.
Thanks,
Re: cant see last label on bottom axis
Posted: Sun Mar 20, 2011 7:13 am
by 14045267
Hi Sandra
thanks for the reply
No , this doesnt work , and I assume that its simply because I dont think there is any connection between Label length and the Margin units
whats the point of measuring the length of the label string , its not the same units as the margin is it. ?
label length represents of characters in the label string , while Margin units i assume is something else
Re: cant see last label on bottom axis
Posted: Mon Mar 21, 2011 10:13 am
by 10050769
Hello rino,
You are right. Numbers of characters are not the same units as MarginUnits. I have made, other code that uses width of bottom labels and PanelMarginsUnits as pixels, and this works fine for me.
Code: Select all
Steema.TeeChart.Styles.Line series1, series2;
private void InitializeChart()
{
//Chart
tChart1.Dock = DockStyle.Fill;
this.tChart1.Aspect.View3D = false;
this.tChart1.Axes.Bottom.MinorTicks.Visible = false;
tChart1.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
//Series
series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
series2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
//tChart1.Panel.MarginRight = 10;
series1.Title = "Series1";
series2.Title = "Series2";
for (int i = 0; i < 3; i++)
{
series1.Add(i * 10, "long label 323253" + i.ToString());
series2.Add(i * 20, "long label 323253" + i.ToString());
}
tChart1.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
tChart1.Draw();
}
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
if (tChart1.Axes.Bottom.Labels.Width / 2 >= tChart1.Panel.MarginRight)
{
tChart1.Panel.MarginRight = (tChart1.Axes.Bottom.Labels.Width/2)+tChart1.Panel.MarginRight;
tChart1.Panel.MarginLeft = (tChart1.Axes.Bottom.Labels.Width / 2) + tChart1.Panel.MarginLeft;
}
}
Could you tell us if previous code works as you want?
I hope will helps.
Thanks,
Re: cant see last label on bottom axis
Posted: Tue Mar 22, 2011 4:11 pm
by 14045267
Hi Sandra
your last code seems to do the correct calculation however it doesnt have effect the first time.
it only works after a second draw of the chart is done, the changes in afterDraw , do not cause the chart to repaint itself , so only when the chart is drawn again will the changes in the margin have effect.
This should be calculated sometime before the draw is performed,
Re: cant see last label on bottom axis
Posted: Wed Mar 23, 2011 11:29 am
by 10050769
Hello rino,
In this case, use tChart1.Draw() is necessary, because you must repaint chart if you want sizes have a correct value and you can use it correctly.
Thanks,
Re: cant see last label on bottom axis
Posted: Wed Mar 23, 2011 3:36 pm
by 14045267
You mean to call Draw from within the AfterDraw event . isnt this a little awkward ?
Also , what is the difference between Draw and Refresh ? which is better.
Re: cant see last label on bottom axis
Posted: Wed Mar 23, 2011 4:02 pm
by 10050769
Hello rino,
You mean to call Draw from within the AfterDraw event . isnt this a little awkward ?
Sorry, I think that I don't explain good. In my code there is a tChart.Draw() in the InititializeChart(), because could repaint chart to achieve the correct values of width of labels shape.
Draw Method:
Paints the Chart internally to calculate Chart values that would otherwise be calculated only when the Chart is actually Painted to the screen.
Refresh Method:
Forces the control to invalidate its client area and immediately redraw itself and any child controls.
In your case its better Draw Method so you need the Chart values.
Thanks,