
12-03-2010, 03:35 PM
|
|
Centurion
|
|
Join Date: Sep 2009
Posts: 111
|
|
How to Change the Line Weight in a the Chart Control?
|
I'm using Visual basic 2010.net with service pack 4.0. I'm using the built in chart control to generate a line graph. I have a series plotted on the fastline graph. Is there a way of accessing the weight/thickness/boldness of the line and changing it? I was able ton change the colour and I could even change the point size on the fastpoint graph. This is my code for anyone who is interested, although I'm not really sure if it's relevant to my post...
Code:
Private Sub DisplayGraph_frm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = CustomizeGraph_frm.GraphTitle_txt.Text
TheChart_cht.ChartAreas("ChartArea").BackColor = CustomizeGraph_frm.BackgroundColor_pnl.BackColor
XMin = CustomizeGraph_frm.DateFrom_dtp.Value.AddHours(CustomizeGraph_frm.TimeFrom_dtp.Value.Hour).AddMinutes(CustomizeGraph_frm.TimeFrom_dtp.Value.Minute)
XMax = CustomizeGraph_frm.DateTo_dtp.Value.AddHours(CustomizeGraph_frm.TimeTo_dtp.Value.Hour).AddMinutes(CustomizeGraph_frm.TimeTo_dtp.Value.Minute)
XRange = DateDiff(DateInterval.Minute, XMin, XMax)
XInterval = CustomizeGraph_frm.ReadingFrequency(CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex)
If CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex >= 10 Then
XUnit = "Minutes"
ElseIf CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex >= 10 And CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex < 15 Then
XUnit = "Days"
ElseIf CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex >= 15 And CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex < 19 Then
XUnit = "Months"
ElseIf CustomizeGraph_frm.ReadingFrequency_cmb.SelectedIndex >= 19 Then
XUnit = "Years"
End If
For i = 0 To Data.Length - 2 Step 1
Data(i) = New Double(XRange / XInterval) {}
For ii = 0 To XRange / XInterval Step 1
Data(i)(ii) = RandomClass.Next(-20, 20)
Next
CurrentChartSeries = CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).Text
If Not CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(4).Text = "Hide Points" Then
TheChart_cht.Series.Add(CurrentChartSeries + " Points")
TheChart_cht.Series(CurrentChartSeries + " Points").ChartType = SeriesChartType.FastPoint
TheChart_cht.Series(CurrentChartSeries + " Points").Color = ColorTranslator.FromHtml(CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(3).Text)
If CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(4).Text = "Small" Then
TheChart_cht.Series(CurrentChartSeries + " Points").MarkerSize = 3
ElseIf CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(4).Text = "Medium" Then
TheChart_cht.Series(CurrentChartSeries + " Points").MarkerSize = 4.5
ElseIf CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(4).Text = "Large" Then
TheChart_cht.Series(CurrentChartSeries + " Points").MarkerSize = 6
End If
For ii = 0 To Data(i).Length - 1 Step 1
TheChart_cht.Series(CurrentChartSeries + " Points").Points.AddY(Data(i)(ii))
Next
End If
TheChart_cht.Series.Add(CurrentChartSeries + " Lines")
TheChart_cht.Series(CurrentChartSeries + " Lines").ChartType = SeriesChartType.FastLine
TheChart_cht.Series(CurrentChartSeries + " Lines").Color = ColorTranslator.FromHtml(CustomizeGraph_frm.WaitingList_lvw.Items.Item(i).SubItems(1).Text)
For ii = 0 To Data(i).Length - 1 Step 1
TheChart_cht.Series(CurrentChartSeries + " Lines").Points.AddY(Data(i)(ii))
Next
Next
End Sub
You don't really need to read all that. But my question still stands, is there a way to change the thickness of a line? It seems "MarkerSize" doesn't work with fastline graphs. Or if it does, I don't know what it actually does do?
Just as another thing, how would I changed the axis colour, axis weight/thickness/boldness, grid style and grid colour. I'm new to chart controls (just started today) I downloaded a file containing a load of information on how to do stuff. Unfortunately, it seems they can't get everything in their. If anyone knows of a good website that has information on Chart Control, please say. I've looked all over the place for information and there is very little. Charts probably aren't popular enough, which is a shame because it looks to me like Microsoft really went all out on them. You can have practically every chart available!
|
|