Populate/generate multiple charts from dataset
June 12, 2013 Leave a comment
I’m assuming you have defined methods to get data to dataset. Please find code below to fill 4 charts. (Also place 4 charts in your form design and name it as chrt, chrt2, chrt3, chrt4)
Private Sub bgwProcessChart_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwProcessChart.DoWork Try Dim GraphDataSet As DataSet = New DataSet ' Loop to fill four charts For i As Integer = 1 To 4 ' Get data for chart (Your Method!) dont worry about it just there to fill dataset GraphDataSet = _access.generateGraph(cde, i) ' Generate Chart - Here I have passed dataset, chartcontrol itself, graph number chartGenerate(GraphDataSet, chrt, i) Next Catch ex As Exception MsgBox("No response from server. Please try again." & Chr(10) & "If this error occurs continuously, please reopen the application." & Chr(10) & ex.Message, MsgBoxStyle.Exclamation, "Data Load Failure") End Try End Sub