#Custom label for vb chart#
I have a datatable like this
XValue | YValue | Title |
---|---|---|
1 | 1 | A |
2 | 2 | B |
3 | 3 | C |
I want to display a vb chart like this
6|
5|
4|
3| *C
2| *B
1| *A
0|______________________
0 1 2 3 4 5 6 7 5 8 9
so far i can only display this
6|
5|
4|
3| *3
2| *2
1| *1
0|______________________
0 1 2 3 4 5 6 7 5 8 9
this is my code below
Chart20.ChartAreas(0).AxisX.Minimum = 60
Chart20.ChartAreas(0).AxisX.Maximum = 220
Chart20.Series("TEMP").Points.Clear()
Try
CONN.Open()
COMMAND = CONN.CreateCommand
QUERY = "SELECT XValue,YValue,Title FROM vitals"
COMMAND = New MySqlCommand(QUERY, CONN)
READER = COMMAND.ExecuteReader
While READER.Read
Chart20.Series("TEMP").Points.AddXY(READER.GetString("YValue"), READER.GetString("XValue"))
End While
CONN.Close()
Catch ex As Exception
CONN.Close()
MsgBox(ex.ToString, MsgBoxStyle.Critical)
End Try
Can you help me out pls
Sub ShowPointLabels()
Chart20.Series("TEMP").Points.Clear()
Try
CONN.Open()
COMMAND = CONN.CreateCommand
QUERY = "SELECT * FROM vitals"
COMMAND = New MySqlCommand(QUERY, CONN)
READER = COMMAND.ExecuteReader
For Each d In READER
Chart20.Series("TEMP").Points(Chart20.Series("TEMP").Points.AddXY(READER.GetString("XValue"), READER.GetString("YValue"))).Label = READER.GetString("Title")
Next
CONN.Close()
Catch ex As Exception
CONN.Close()
MsgBox(ex.ToString, MsgBoxStyle.Critical)
End Try
End Sub
I modified @Andrew Morton Answer to a simplified result and it works perfectly for me. I hope this helps somebody as well