Wednesday, November 11, 2009 4:00 AMHello,
I'm trying to format the values listed along the X-Axis and Y-Axis (chart image linked below). So far i've managed to get the marker intervals consistent along both axes by manually setting the AxisX.Minimum and AxisY.Minimum properties (not shown in the image). There are a couple of things i'd really like to do that i haven't been able to figure out:
Firstly, is it possible to format the values to two decimal places? I'm pulling the values for the series straight out of a database table and would prefer not to format the value in my SQL select but rather in the code. I tried using FormatNumber() around the values in my call to Points.AddXY() but that was problematic as it seemed to make the X-axis gridline markers disappear altogether.
Secondly, given that the AxisX.Minimum and AxisY.Minimum values are equal, how would i go about showing the interval markers going up by, say for example, whole numbers. The chart origin in the image is (14.73~, 14.73~) - is it possible to have the chart show gridlines at 15, 16, 17, 18, ..max(x)/max(y) along X and Y or are we stuck with what the built in algorithm gives us?
I'm on filtered net access from the office so i had to get a friend to upload this, but hopefully the image is accessible from one of these links:
Thanking you in advance,
Wednesday, November 11, 2009 4:16 AMIf possible, I'd also like to add a percentage symbol (%) after each x/y axis marker (e.g. 14.73%, 20%, etc.)
Wednesday, November 11, 2009 4:58 AM
Use the following to display values upto 2 decimal points
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Wednesday, November 11, 2009 10:28 AMModerator
The formatting should work as KishorePV showed.. just add a % to the end of the format string for the percentage symbol.
You can adjust the axis intervals with Axis.IntervalOffset.
Something like this should work in your case:
ChartArea.AxisY.IntervalOffset = -(area.AxisY.Minimum - Math.Truncate(area.AxisY.Minimum)) 'with a minimum of 14.73 the offset would be -0.73
You'll lose the AxisY.Minimum label this way though. You could try to add the minimum label in the customize event:
Private Sub Chart1_Customize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Chart1.Customize Dim chart As Chart = CType(sender, Chart) Dim area As ChartArea = chart.ChartAreas(0) area.AxisY.CustomLabels.Add(area.AxisY.Minimum - 0.2, area.AxisY.Minimum + 0.2, area.AxisY.Minimum & "%") End Sub
- Marked As Answer by hyperkarma Thursday, November 12, 2009 4:29 AM
Thursday, November 12, 2009 4:29 AMThanks very much to you both - i managed to resolve the issue with your suggestions :)