Results 1 to 10 of 10

Thread: Formatting the chart control

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Formatting the chart control

    Hey,

    The chart control is doing whatever it likes, and I'm looking for a way to control how it outputs axes values and how to set a specific scale. This is my current problem.

    The scale on the X axis is decreasing, by default.
    I also would like to limit the labels to 1 decimal place.

    Name:  scales and axes.JPG
Views: 3673
Size:  47.0 KB

    Cheers

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Formatting the chart control

    Formatting Axes

    Name:  Step_01.png
Views: 3090
Size:  24.4 KB
    Name:  Step_02.png
Views: 3309
Size:  37.2 KB
    Name:  Step_03.png
Views: 3105
Size:  41.1 KB
    Name:  Step_04.png
Views: 3132
Size:  40.4 KB

    Controlling Scaling
    Name:  Step_01.png
Views: 3090
Size:  24.4 KB
    Name:  Step_02.png
Views: 3309
Size:  37.2 KB
    Name:  Step_03.png
Views: 3265
Size:  38.3 KB

    Hope that helps. You'd most likely benefit by downloading the charting samples provided by Microsoft where they give tons of examples of doing various things.

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Re: Formatting the chart control

    Thanks for your detailed and helpful reply, and I'm sorry for my extremely late one. For some reason it doesn't seem to be as simple a fix as above, the Y axis obeys:

    Code:
     Chart1.ChartAreas(0).AxisY.LabelStyle.Format = "N1"
    However for the X axis it is ineffective.I don't think it is being overwritten at another point, because this is all the code I have relating to the chart:

    Code:
     Dim series_1 As New Series
            series_1.ChartType = SeriesChartType.Spline
            series_1.XValueMember = ("X values")
            series_1.YValueMembers = ("Y values")
    
            Chart1.Series.Add(series_1)
            Chart1.DataSource = ARpassover_table
    
    
            Chart1.ChartAreas(0).AxisX.LabelStyle.Format = "N1"
    Also, changing the interval values didn't help with the scale either, it just removed the intervals in most cases, the shape of the graph never changed. I think it is because the data is bottom heavy, there are more values in the 2nd half of the data than the first. I think the chart is trying to compensate by making the intervals smaller by default, but whenever I change the intervals it just removes them. Any more ideas?

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Re: Formatting the chart control

    With this code :
    Code:
      With Chart1.ChartAreas(0)
                .AxisX.Minimum = 0
                .AxisX.Maximum = 32
                .AxisY.Minimum = 0
                .AxisY.Maximum = 40
                ' .AxisX.Interval = 1
                .AxisX.Title = "X-Distance (m)"
                .AxisY.Title = "Y-Distance (m)"
                .AxisY.LabelStyle.Format = "N1"
                .AxisX.LabelStyle.Format = "N1"
            End With
    it returns this :
    Name:  my problem 2.0.JPG
Views: 3195
Size:  55.7 KB

    Now why does it make the Y axis go up to 40, whilst limiting the X axis to 32 points of data! I thought it would make both go to the specified value. Is there some major difference in the way it handles X and Y axis formatting?

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Re: Formatting the chart control

    Progress! - Looping through to add the data allows me to show you how it should look, anyone know of a way to still have it bound to a datatable and recreate these results?

    Name:  progress.JPG
Views: 3393
Size:  54.9 KB

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Re: Formatting the chart control

    Using
    Code:
       For Each row As DataRow In ARpassover_table.Rows
                Chart1.Series(0).Points.AddXY(row.Item(0), row.Item(1))
    
            Next row
    puts me back at square one. And yes, I am talking to myself, it helps :P

    Is there a way to disable the automatic stuff when databinding stuff to charts?

  7. #7
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Re: Formatting the chart control

    My question is how can I format a bar chart. The color of the bar is blue. Can I use a different color for each bar? How?



    Last edited by Jose_VB; Apr 21st, 2013 at 03:28 PM.

  8. #8

    Thread Starter
    Member
    Join Date
    Jun 2012
    Posts
    58

    Re: Formatting the chart control

    I think that's just the default image for charts, but you should really create a new thread for this, good luck.

  9. #9
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Re: Formatting the chart control

    I will use this thread. If no one answers then I will open a new one.

  10. #10
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Re: Formatting the chart control

    I've found in other forum that answers:
    Chart1.Series(0).Points(1).Color = Color.Beige

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width