Click here to Skip to main content
15,888,733 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have several graphs which show huge numbers in millions of billions on the primary and secondary Y axis.
The raw data that is provided into it is as such. Now because of displaying these huge numbers, im facing space issues.

is there a way to dynamically change the Y axis labels to have a 'k' for thousand and strip of the '000' 3 zeros.

regards
Joe
Posted

That's determined by your charting library. If it doesn't have any funtion to format the y-axis labels, it should have some function so you can provide those labels yourself.
 
Share this answer
 
Comments
joe_j 26-Jul-12 7:56am    
Not quite sure on how to do that. would you be able to provide me with a way to do that please
Dave Kreskowiak 26-Jul-12 9:55am    
Next time you ask a question, specify what library you are using. Without that everyone is just guessing at what you can and cannot do and what the code is supposed to be.

I still don't have any idea which charting library you're using, so there's no way anyone could possible give you an exact answer.
joe_j 26-Jul-12 9:58am    
i am using the default charts that come with VS 2010. guess its a bit confusing with default library. But anyways, guess its working now. though i did take some time to find it out
Dave Kreskowiak 26-Jul-12 16:41pm    
It would have been nice if you provided everyone with that little tidbit in your original post. There are probably a hundred different graphing libraries out there, each with differing capabilities.
k guess after some experimenting and some extensive googling, got a way to substitute 1K for 1000
the exact solution to my problem is as below

VB
Protected Sub Chart1_FormatNumber(sender As Object, e As System.Web.UI.DataVisualization.Charting.FormatNumberEventArgs) Handles Chart1.FormatNumber
 If (e.ElementType = DataVisualization.Charting.ChartElementType.AxisLabels) Then
            If e.Value > 10000 Then
                e.LocalizedValue = e.Value / 1000 & "k"
            End If
End If
End Sub



hope this would be useful to others as well.

thanks
 
Share this answer
 
v3
Comments
KindaWild 21-Mar-24 1:00am    
12 years later in 2024 and your solution helped me out, Joe. Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900