wallsy Posted September 24, 2007 Report Share Posted September 24, 2007 Hi, I have a chart with y-axis labels that I don't know how to align properly. I would like to left-align the values. The values are: A++ A+ A A- A-- B++ B+ B etc... I have tried padding the labels out with spaces on the right - but they must be trimmed of any whitespace before rendering as it does not have any effect. Any ideas? Is this possible? Thanks, Dan. ps. See attached image as well for further example of where I'm up to. Quote Link to comment Share on other sites More sharing options...
Frank Posted September 26, 2007 Report Share Posted September 26, 2007 Padding is the only way but you need to change the font to a Fixed width font (e.g. Courier New) so that the spaces occupy the same space as other characters. Quote Link to comment Share on other sites More sharing options...
wallsy Posted September 27, 2007 Author Report Share Posted September 27, 2007 I tried the following - but it didn't work. scoreTrendChart.AxisY.Font = new Font("Courier New",10); scoreTrendChart.AxisY.Label[0] = ""; scoreTrendChart.AxisY.Label[1] = "E--"; scoreTrendChart.AxisY.Label[2] = "E- "; scoreTrendChart.AxisY.Label[3] = "E "; scoreTrendChart.AxisY.Label[4] = "E+ "; scoreTrendChart.AxisY.Label[5] = "E++"; any ideas? Thanks,Dan. Quote Link to comment Share on other sites More sharing options...
wallsy Posted September 27, 2007 Author Report Share Posted September 27, 2007 Or the other thing that would help is to turn them off completely? How would I do that? ie. no y-axis labels? thanks, dan. Quote Link to comment Share on other sites More sharing options...
Frank Posted October 2, 2007 Report Share Posted October 2, 2007 To hide the Y-Axis labels: chart.AxisY.Style |= AxisStyle.HideLabels; For some reason .NET is trimming your strings when drawing them right-aligned. I debugged the code and the strings are correct (with the spaces) all the way to the .NET API call. Weird :-( You could replace the last space with some other character (there are a few in COurier New that are pretty small). For example: chart1.AxisY.Label[0] = ""; chart1.AxisY.Label[1] = "E--"; chart1.AxisY.Label[2] = "E-\x2D1"; chart1.AxisY.Label[3] = "E \x2D1"; chart1.AxisY.Label[4] = "E+\x2D1"; chart1.AxisY.Label[5] = "E++"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.