Annotation String Position
Annotation String Position
I need to center the string on an annotation horizontally. If I use AnnotationChart.Shape.TextAlign = StringAlignment.Center, the string should be centered horizontally? However, I can only get it positioned in the left near position?
Re: Annotation String Position
Hello lilo,
If you use the Annotation tool property TextAlign and choose Center option, the text is Centered in the center of the Annotation tool, if you choose near option, it is aligned to left bound of rectangle and if you choose far option, the text is aligned to right bound of rectangle. See next code to check it:
Please, could you check my code and tell us if it works in your end? If you consider it doesn't work properly for you, could you please tell us why?
Thanks,
If you use the Annotation tool property TextAlign and choose Center option, the text is Centered in the center of the Annotation tool, if you choose near option, it is aligned to left bound of rectangle and if you choose far option, the text is aligned to right bound of rectangle. See next code to check it:
Code: Select all
Steema.TeeChart.TChart tChart1;
public Form1()
{
InitializeComponent();
tChart1 = new TChart();
this.Controls.Add(tChart1);
// tChart1.Dock = DockStyle.Fill;
tChart1.Top = 150;
tChart1.Left = 100;
tChart1.Height = 400;
tChart1.Width = 550;
tChart1.Aspect.View3D = false;
InitializeChart();
}
private void InitializeChart()
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Tools.Annotation an = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
bar1.FillSampleValues();
an.Text = " Steema Software";
an.TextAlign = StringAlignment.Center;
button1.Click += button1_Click;
checkBox1.Checked = true;
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox1.CheckedChanged += checkBox1_CheckedChanged;
checkBox2.CheckedChanged += checkBox2_CheckedChanged;
checkBox3.CheckedChanged += checkBox3_CheckedChanged;
}
void checkBox3_CheckedChanged(object sender, EventArgs e)
{
Steema.TeeChart.Tools.Annotation tool = (tChart1.Tools[0] as Steema.TeeChart.Tools.Annotation);
if (checkBox3.Checked)
{
tool.TextAlign = StringAlignment.Far;
checkBox1.Checked = false;
checkBox2.Checked = false;
}
}
void checkBox2_CheckedChanged(object sender, EventArgs e)
{
Steema.TeeChart.Tools.Annotation tool = (tChart1.Tools[0] as Steema.TeeChart.Tools.Annotation);
if (checkBox2.Checked)
{
tool.TextAlign = StringAlignment.Near;
}
checkBox1.Checked = false;
checkBox3.Checked = false;
}
void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Steema.TeeChart.Tools.Annotation tool = (tChart1.Tools[0] as Steema.TeeChart.Tools.Annotation);
if (checkBox1.Checked)
{
tool.TextAlign = StringAlignment.Center;
}
checkBox2.Checked = false;
checkBox3.Checked = false;
}
void button1_Click(object sender, EventArgs e)
{
tChart1.ShowEditor();
}
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: Annotation String Position
Hi Sandra,
Thanks, it does work correctly...my problem was I did not set the annotation.width property correctly.
lilo
Thanks, it does work correctly...my problem was I did not set the annotation.width property correctly.
lilo
Re: Annotation String Position
Hello lilo,
I am glad your problem solved.
Thanks,
I am glad your problem solved.
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: Annotation String Position
Hi Sandra,
I struck another problem, the centering works fine for a text string with two characters or more, but does not work with one character. How can I center one character?
I struck another problem, the centering works fine for a text string with two characters or more, but does not work with one character. How can I center one character?
Re: Annotation String Position
Hello lilo,
I have changed the Annotation Tools string Steema Software to A and it is centered correctly, you can check it in my attached project. If in my project your problem doesn't occurs, but in your project the problem appears, could you please send us your project and tell us which version are you using, because can suggest you a good solution? Thanks,
I have changed the Annotation Tools string Steema Software to A and it is centered correctly, you can check it in my attached project. If in my project your problem doesn't occurs, but in your project the problem appears, could you please send us your project and tell us which version are you using, because can suggest you a good solution? 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: Annotation String Position
Thanks Sandra,
I can't open your project, as I am still using Visual Studio 2010...I might have to download an express version. In the meantime, I am able to workaround the problem by setting the annotation width and height manually to the character width and height.
I can't open your project, as I am still using Visual Studio 2010...I might have to download an express version. In the meantime, I am able to workaround the problem by setting the annotation width and height manually to the character width and height.
Re: Annotation String Position
Hello lilo,
I have modified my project, because you can use it in VS2010. Could you test my attached project? Thanks,
I have modified my project, because you can use it in VS2010. Could you test my attached project? 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: Annotation String Position
Hi Sandra,
Thanks, your project works fine. My project(s) will not work. I am using Visual Basic Net 2010 TeeChart V 4.1.2012.1312.
I am creating the annotation tools at runtime without the edit window.
Private Sub TChart1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseDown
NumText = NumText + 1
ReDim Preserve AnnotationChart(NumText)
AnnotationChart(NumText) = New Steema.TeeChart.Tools.RectangleTool(TChart1.Chart)
AnnotationChart(NumText).PositionUnits = Steema.TeeChart.PositionUnits.Pixels
AnnotationChart(NumText).Shape.TextAlign = StringAlignment.Center
AnnotationChart(NumText).AllowResize = True
AnnotationChart(NumText).AllowEdit = True
AnnotationChart(NumText).AllowDrag = True
AnnotationChart(NumText).AutoSize = True
AnnotationChart(NumText).ClipText = True
AnnotationChart(NumText).Shape.Transparent = True
AnnotationChart(NumText).Shape.Font.Color = FontColor
AnnotationChart(NumText).Shape.Font.Name = NewTextFont
AnnotationChart(NumText).Shape.Font.Size = NewTextSize
AnnotationChart(NumText).Shape.Font.Bold = NewTextBold
AnnotationChart(NumText).Shape.Font.Italic = NewTextItalic
AnnotationChart(NumText).Shape.Font.Underline = NewTextUnderline
AnnotationChart(NumText).Shape.CustomPosition = True
AnnotationChart(NumText).Text = SymbolType
AnnotationChart(NumText).EndEdit()
AnnotationChart(NumText).Left = e.X - (AnnotationChart(NumText).Width / 2)
AnnotationChart(NumText).Top = e.Y - (AnnotationChart(NumText).Bounds.Height / 2)
AnnotationChart(NumText).Shape.Visible = True
Thanks, your project works fine. My project(s) will not work. I am using Visual Basic Net 2010 TeeChart V 4.1.2012.1312.
I am creating the annotation tools at runtime without the edit window.
Private Sub TChart1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseDown
NumText = NumText + 1
ReDim Preserve AnnotationChart(NumText)
AnnotationChart(NumText) = New Steema.TeeChart.Tools.RectangleTool(TChart1.Chart)
AnnotationChart(NumText).PositionUnits = Steema.TeeChart.PositionUnits.Pixels
AnnotationChart(NumText).Shape.TextAlign = StringAlignment.Center
AnnotationChart(NumText).AllowResize = True
AnnotationChart(NumText).AllowEdit = True
AnnotationChart(NumText).AllowDrag = True
AnnotationChart(NumText).AutoSize = True
AnnotationChart(NumText).ClipText = True
AnnotationChart(NumText).Shape.Transparent = True
AnnotationChart(NumText).Shape.Font.Color = FontColor
AnnotationChart(NumText).Shape.Font.Name = NewTextFont
AnnotationChart(NumText).Shape.Font.Size = NewTextSize
AnnotationChart(NumText).Shape.Font.Bold = NewTextBold
AnnotationChart(NumText).Shape.Font.Italic = NewTextItalic
AnnotationChart(NumText).Shape.Font.Underline = NewTextUnderline
AnnotationChart(NumText).Shape.CustomPosition = True
AnnotationChart(NumText).Text = SymbolType
AnnotationChart(NumText).EndEdit()
AnnotationChart(NumText).Left = e.X - (AnnotationChart(NumText).Width / 2)
AnnotationChart(NumText).Top = e.Y - (AnnotationChart(NumText).Bounds.Height / 2)
AnnotationChart(NumText).Shape.Visible = True
Re: Annotation String Position
Hello lilo,
Could you please, send us your project because we can reproduce your problem here and try to find the issue and try to give you a solution?
Thanks,
Could you please, send us your project because we can reproduce your problem here and try to find the issue and try to give you a solution?
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: Annotation String Position
Hi Sandra,
Attached is a project for visual studio 2010.
Attached is a project for visual studio 2010.
- Attachments
-
- CenterAnnotationTest (2).zip
- (178.72 KiB) Downloaded 856 times
Re: Annotation String Position
Hello lilo,
I have found your problem. It seems appears when you access to the RectangleTool TextAlign property, using the Shape of this tool as do in next line of code:
In this point, you must know you can access to RectangleTool TextAlign property directly, without using shape. I have changed it in your code and the problem of align disappears. You can see the modification, in next lines of code:
Could you tell us if previous code solve your problem?
I hope will helps.
Thanks,
I have found your problem. It seems appears when you access to the RectangleTool TextAlign property, using the Shape of this tool as do in next line of code:
Code: Select all
AnnotationChart(NumText).Shape.TextAlign = StringAlignment.Center
Code: Select all
Private Sub TChart1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles TChart1.MouseDown
NumText = NumText + 1
ReDim Preserve AnnotationChart(NumText)
AnnotationChart(NumText) = New Steema.TeeChart.Tools.RectangleTool(TChart1.Chart)
AnnotationChart(NumText).PositionUnits = Steema.TeeChart.PositionUnits.Pixels
AnnotationChart(NumText).TextAlign = StringAlignment.Center
AnnotationChart(NumText).AllowResize = True
AnnotationChart(NumText).AllowEdit = True
AnnotationChart(NumText).AllowDrag = True
AnnotationChart(NumText).AutoSize = True
AnnotationChart(NumText).ClipText = True
'Change Shape.
AnnotationChart(NumText).Shape.Visible = True
AnnotationChart(NumText).Shape.Pen.Visible = True
AnnotationChart(NumText).Shape.Transparent = False 'True
AnnotationChart(NumText).Shape.Font.Color = Color.Black
AnnotationChart(NumText).Shape.Font.Name = "Arial" 'NewTextFont
AnnotationChart(NumText).Shape.Font.Size = 26 'NewTextSize
AnnotationChart(NumText).Shape.Font.Bold = False 'NewTextBold
AnnotationChart(NumText).Shape.Font.Italic = False 'NewTextItalic
AnnotationChart(NumText).Shape.Font.Underline = False 'NewTextUnderline
AnnotationChart(NumText).Shape.CustomPosition = True
AnnotationChart(NumText).Text = "+"
AnnotationChart(NumText).EndEdit()
AnnotationChart(NumText).Left = e.X - (AnnotationChart(NumText).Width / 2)
AnnotationChart(NumText).Top = e.Y - (AnnotationChart(NumText).Bounds.Height / 2)
End Sub
I hope will helps.
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: Annotation String Position
Thanks Sandra,
This solved the problem.
This solved the problem.