1 Attachment(s)
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.
Attachment 98421
Cheers
5 Attachment(s)
Re: Formatting the chart control
Formatting Axes
Attachment 98433
Attachment 98435
Attachment 98437
Attachment 98439
Controlling Scaling
Attachment 98433
Attachment 98435
Attachment 98441
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.
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?
1 Attachment(s)
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 :
Attachment 98879
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?
1 Attachment(s)
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?
Attachment 98883
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?
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?
http://img545.imageshack.us/img545/5308/image12dz.png
http://img202.imageshack.us/img202/4043/chart2.png
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.
Re: Formatting the chart control
I will use this thread. If no one answers then I will open a new one.
Re: Formatting the chart control
I've found in other forum that answers:
Chart1.Series(0).Points(1).Color = Color.Beige