Trouble adding comma to bar graph data using Windows Chart Class

curiouswebster
curiouswebster used Ask the Experts™
on
Trouble adding comma to bar graph data using Windows Chart Class

I am using the library:
System.Windows.Forms.DataVisualization.Charting

and found I could format (with comma) for values > 1,000

with this line of code:
ca.AxisY.LabelStyle.Format = ("##,#");

But, I can't figure out how to get the data to display also with the comma.

Best I get is the following:
Missing Comma on Data
Here is the Microsoft reference document:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.chart?view=netframework-4.0
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Rikin ShahMicrosoft Dynamics CRM Consultant
Commented:
Hi,

Just need to update with curly brackets.

ca.AxisY.LabelStyle.Format = {"##,#"};

Refer- https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings?redirectedfrom=MSDN#SpecifierTh
Eduard GherguArchitect - Coder - Mentor
Commented:
Hi,

Could you try: ca.AxisY.LabelStyle.Format = "{##,#}";
curiouswebsterSoftware Engineer

Author

Commented:
This one compiles:
ca.AxisY.LabelStyle.Format = "{##,#}";

But behaves just like
ca.AxisY.LabelStyle.Format = ("##,#");

Y-Axis labels are formatted with a comma, but the value above each bar does not have a comma. (Same as Chart above)
Top Expert 2016
Commented:
to format data point labels you need code like

Chart1.Series(0).LabelFormat = "{#,##}"

Sara
curiouswebsterSoftware Engineer

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial