Ik gebruik Visual Basic .NET 2003, en ik heb het volgende probleem:
ik wil een grafiek maken van een datagrid, of van een csv file. Hoe doe ik dit? Ik heb al naar veel examples gezocht voor de MSchart, maar dezze zijn meestal allemaal in VB6. Ik kan wel de data zelf ingeven wat ik in de grafiek wil hebben, zie de volgende code:
Private Sub Chtsales_ChartSelected(ByVal sender As System.Object, ByVal e As AxMSChart20Lib._DMSChartEvents_ChartSelectedEvent) Handles Chtsales.ChartSelected
Dim Athletes(,) As Object = New Object(,) _
{{"Athletes", "Athlete 1", "Athlete 2", "Athelete 3", "Athlete 4", "Athlete 5", "Athelete 6"}, _
{"Heartrate 1", 300, 50, 60, 50, 60, 50}, _
{"Heartrate 2", 60, 90, 60, 50, 60, 50}, _
{"Heartrate 3", 60, 90, 60, 50, 60, 50}, _
{"Heartrate 4", 40, 50, 60, 50, 60, 50}, _
{"Heartrate 5", 60, 50, 90, 50, 60, 50}, _
{"Heartrate 6", 60, 50, 60, 50, 60, 50}, _
{"Heartrate 7", 60, 50, 90, 50, 60, 50}, _
{"Heartrate 8", 60, 50, 60, 50, 60, 50}}
Chtsales.ChartData = Athletes
'Add a title and legend.
With Me.Chtsales
.Title.Text = "Heart rates"
.Legend.Location.LocationType = _
MSChart20Lib.VtChLocationType.VtChLocationTypeBottom
.Legend.Location.Visible = True
End With
'Add titles to the axes.
With Me.Chtsales.Plot
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Athlete nr"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Beats per minute"
End With
'Set custom colors for the bars.
With Me.Chtsales.Plot
'Yellow for Company A
' -1 selects all the datapoints.
.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(250, 250, 0)
'Purple for Company B
.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(300, 150, 200)
.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set(100, 350, 200)
.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set(300, 50, 200)
.SeriesCollection(5).DataPoints(-1).Brush.FillColor.Set(800, 250, 200)
.SeriesCollection(6).DataPoints(-1).Brush.FillColor.Set(900, 50, 200)
End With
End Sub
Met deze code schrijf ik dus de data rechstreeks de MSchart grafiek in, maar ik wil dus eigenlijk een csv file openen, of de grafiek aan een datagrid koppelen, en dat Visual Basic dan vanzelf de grafiek genereert. weet iemand hoe en of dit mogelijk is, en anders of ik eventueel andere chart software nodig heb?
ik wil een grafiek maken van een datagrid, of van een csv file. Hoe doe ik dit? Ik heb al naar veel examples gezocht voor de MSchart, maar dezze zijn meestal allemaal in VB6. Ik kan wel de data zelf ingeven wat ik in de grafiek wil hebben, zie de volgende code:
Private Sub Chtsales_ChartSelected(ByVal sender As System.Object, ByVal e As AxMSChart20Lib._DMSChartEvents_ChartSelectedEvent) Handles Chtsales.ChartSelected
Dim Athletes(,) As Object = New Object(,) _
{{"Athletes", "Athlete 1", "Athlete 2", "Athelete 3", "Athlete 4", "Athlete 5", "Athelete 6"}, _
{"Heartrate 1", 300, 50, 60, 50, 60, 50}, _
{"Heartrate 2", 60, 90, 60, 50, 60, 50}, _
{"Heartrate 3", 60, 90, 60, 50, 60, 50}, _
{"Heartrate 4", 40, 50, 60, 50, 60, 50}, _
{"Heartrate 5", 60, 50, 90, 50, 60, 50}, _
{"Heartrate 6", 60, 50, 60, 50, 60, 50}, _
{"Heartrate 7", 60, 50, 90, 50, 60, 50}, _
{"Heartrate 8", 60, 50, 60, 50, 60, 50}}
Chtsales.ChartData = Athletes
'Add a title and legend.
With Me.Chtsales
.Title.Text = "Heart rates"
.Legend.Location.LocationType = _
MSChart20Lib.VtChLocationType.VtChLocationTypeBottom
.Legend.Location.Visible = True
End With
'Add titles to the axes.
With Me.Chtsales.Plot
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdX).AxisTitle.Text = "Athlete nr"
.Axis(MSChart20Lib.VtChAxisId.VtChAxisIdY).AxisTitle.Text = "Beats per minute"
End With
'Set custom colors for the bars.
With Me.Chtsales.Plot
'Yellow for Company A
' -1 selects all the datapoints.
.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(250, 250, 0)
'Purple for Company B
.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(300, 150, 200)
.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set(100, 350, 200)
.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set(300, 50, 200)
.SeriesCollection(5).DataPoints(-1).Brush.FillColor.Set(800, 250, 200)
.SeriesCollection(6).DataPoints(-1).Brush.FillColor.Set(900, 50, 200)
End With
End Sub
Met deze code schrijf ik dus de data rechstreeks de MSchart grafiek in, maar ik wil dus eigenlijk een csv file openen, of de grafiek aan een datagrid koppelen, en dat Visual Basic dan vanzelf de grafiek genereert. weet iemand hoe en of dit mogelijk is, en anders of ik eventueel andere chart software nodig heb?