Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotate Text - Y-Axis Title 1

Status
Not open for further replies.
Mar 9, 2006
93
CA
I have created a graphing program. I am going to put a title along the YAxis of the bar graph. Does anyone know how I can rotate the text so it is vertical from bottom to top instead of Horizontal from left to right?
thanks
Matt
 

only works with ie, so if you need compatibility this will not work.

The only other method that I can think would be plausable is to convert the text to an image. There are a lot of tutorials doing this with php but I havn't yet seen any good tutorials with c#
 
Ah - you didn't say this was a web-app.

In that case you really are best to save the image and rotate it.
 
JurkMonkey,
I went to the link and it did write the text vertically but it created it vertically from top to bottom (Rotated 90 degrees) instead of vertically from bottom to top (Rotated 270 degrees). Also this is not a web app it is a windows application.
 
I can look into this more later... but have you tried a transformation?

This is using a picturebox but it should work for a label too

private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;


g.TranslateTransform(100.0f, 100.0f);
g.RotateTransform(-90.0f);
g.DrawString("Vertical Text", Font, Brushes.Blue, 0.0f, 0.0f);
g.ResetTransform();


g.TranslateTransform(100.0f, 100.0f);
g.RotateTransform(-45.0f);
g.DrawString("Slanted Text", new Font(Font, FontStyle.Bold), Brushes.Red, 0.0f, 0.0f);
g.ResetTransform();


}


taken from

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top