zanie 0 Newbie Poster

Dear Experts,

I explain first the scenario. In one vb form, I have 2 tables connected through ID(relationship from MS Access).In the first table the fields are NameID, Company, Name, Grade and on the second table the fields are ExamID, NameID, Date, Score1, Score2, Score3, and Average. Now, I want to create a chart based on the selected row only (ExamID 1,2,3, .....) in one NameID, and also the Name will appear in the lower part of the chart. The contents of the chart are Y-axis- Score, X-axis- ExamID and lower part Name. I have here codes, but my problem is all NameID was graph in chart.

Here is my code:

Imports System.Data

Imports System.Data.OleDb

Public Class AssessmentChart

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.table2TableAdapter.Fill(Me.DataSet1.table2)

Me.table1TableAdapter1.Fill(Me.DataSet1.table1)

Dim Dtable2 As DataTable = DataSet1.table1

Dim Dtable As DataTable = DataSet1.table2

Dim xval As String = Dtable.Columns(1).ToString

Dim xval2 As String = Dtable2.Columns(3).ToString

Chart1.DataSource = BindingSource1

 

Chart1.Series(0).Color = Color.SteelBlue

Chart1.Series(1).Color = Color.Olive

Chart1.Series(2).Color = Color.MediumPurple

Chart1.Series(3).Color = Color.Firebrick

 

'Give names to Series1 and Series 2

Chart1.Series(0).Name = "Score1"

Chart1.Series(1).Name = "Score2"

Chart1.Series(2).Name = "Score3"

Chart1.Series(3).Name = "Average"

'associate series with column names

Chart1.Series(0).XValueMember = Dtable.Columns(1).ToString

Chart1.Series(0).YValueMembers = Dtable.Columns(4).ToString

Chart1.Series(1).YValueMembers = Dtable.Columns(5).ToString

Chart1.Series(2).YValueMembers = Dtable.Columns(6).ToString

Chart1.Series(3).YValueMembers = Dtable.Columns(7).ToString

Chart1.Series(4).YValueMembers = Dtable.Columns(8).ToString

Chart1.Series(5).YValueMembers = Dtable.Columns(9).ToString

 

Chart1.Series(0).XValueMember = xval

Chart1.Series(1).XValueMember = xval

Chart1.Series(2).XValueMember = xval

Chart1.Series(3).XValueMember = xval

'bind the data to chart

Chart1.DataBind()

Chart1.Visible = True

End Sub

End Class

Best Regards,

Jaxie

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.