שתף באמצעות


Y- Axis scale on VB.NET chart

Question

Wednesday, December 6, 2017 3:07 PM

Hi Everyone,

I have been struggling throughout with something that should be straightforward :)

I have created a column chart but now cant scale my y -values correctly.My quanity shows in 'millions' instead of in 'units'.

Where and how do I change that, either on chart properties (Design) or with code.

When designing it it looks like this:

but when I run it I see this.

Thank you in advance.

Siboniso

All replies (3)

Wednesday, December 6, 2017 3:56 PM ✅Answered | 2 votes

Have a look at this. It is a Visual Studio project you download and run. Has much info on the chart.

Then come back if you cant find the problem. Show a code sample of what you have.

https://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61


Wednesday, December 6, 2017 8:13 PM | 1 vote

Perhaps this can help Labels in Chart Controls.

Also note as Labels are strings that some possibilities are available to assist in representing various string types a certain way I believe (according to what I saw at the above link) so perhaps the below links may assist with that if necessary.

Here is a link to this forums search results for ChartControl and maybe some of the threads can assist you.

La vida loca


Thursday, December 7, 2017 6:34 AM | 1 vote

Hi Sisyb,

According to your description, you want to scale y value in chart. For example the value is 1000000, you want to display 1M, am I right? If yes, you can take a look the following code:

        Dim dt1 As New DataTable
        dt1.Columns.Add("Xvalue", GetType(String))
        dt1.Columns.Add("Yvalue", GetType(Integer))
        dt1.Rows.Add("A", 1000000)
        dt1.Rows.Add("B", 2000000)
        dt1.Rows.Add("C", 3000000)
        dt1.Rows.Add("D", 4000000)
        dt1.Rows.Add("E", 5000000)
        Chart1.DataSource = dt1
        Chart1.Series("Series1").XValueMember = "Xvalue"
        Chart1.Series("Series1").YValueMembers = "Yvalue"
       
        Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "0,,.0M"

Best Regards,

Cherry

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.