Click here to Skip to main content
15,851,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, I have some charts in my vb.net forms which I would like to make them more sophisticated . I have been googling but I haven't found anything so specific.
I just want to know if it's possible and what method should I use or which direction should I go to..


I have connected my chart with SQL database values.

Here is some of the code that I use it:
Private Sub LoaddayData()

       Chartday.DataSource = GetData1()
       Chartday.Series("Day").Points.Clear()
       Chartday.Series("Day").XValueMember = "Day"
       Chartday.Series("Day").YValueMembers = "Total"
       Chartday.Series("Day").ChartType = SeriesChartType.Spline
       Chartday.Series("Day").IsValueShownAsLabel = True
End Sub

Private Function GetData1() As DataTable

       Dim dtChartData As New DataTable()

       Using conn As New SqlConnection(ConfigurationManager.ConnectionStrings("db").ConnectionString)
           Using cmd As New SqlCommand("Chart_daily1", conn) ' Total working hours in the month -- step3
               cmd.CommandType = CommandType.StoredProcedure

               conn.Open()
               'Counts Year only'
               cmd.Parameters.AddWithValue("@DateD", DateTimePickerM.Text)
               cmd.Parameters.AddWithValue("@Department", ComboBoxDepartment.Text)

               Dim reader As SqlDataReader = cmd.ExecuteReader()
               dtChartData.Load(reader)

           End Using
       End Using

       Return dtChartData

   End Function

Thank you,
Your help is appreciated.

What I have tried:

Here are some examples that I have been trying but here it shows only the information that already is in the datachart How to display information of a line chart by doing mouse over[^]


So I was wondering if it is possible to show more information by selecting or just moving the mouse over the curve. Like a list of information or some of that kind.

Thank you,
Best Rergards
Posted
Updated 24-Jul-20 5:33am
v2

1 solution

The "info" is displayed via the .Text property of the CalloutAnnotation object (in the example); add any extra info you want.
With ta
    .AnchorDataPoint = Chart1.Series(0).Points(result.PointIndex)
    .X = thisPt.X + 1
    .Y = thisPt.Y + 1
    .Text = thisPt.ToString
    .CalloutStyle = CalloutStyle.SimpleLine
    .ForeColor = Color.Red
    .Font = New Font("Tahoma", 12, FontStyle.Bold)
End With
 
Share this answer
 
v2
Comments
Member 13410460 22-Jul-20 13:30pm    
Thank you for your reply and help, I will test it now.
Bests
Member 13410460 22-Jul-20 16:39pm    
I looked into that but still don't know how to do it, it looks fairly complicated for my level of coding.
Gerry Schmitz 23-Jul-20 0:36am    
It's as hard as you want to make it. You can dedicate a multi-line textbox (or any other "list type control") on the form for "logging" instead of "annotating". It's called designing; the limits are your imagination.
Member 13410460 24-Jul-20 10:08am    
Is there a chance that I can Connect my SQL Query inside of it ?
For example here in this form :

Dim thisPt As New PointF(CSng(Chartday.Series("Day").Points(Result.PointIndex).XValue),
CSng(Chartday.Series("Day").Points(Result.PointIndex).YValues(0)))

And if yes , how can I do that ?
Gerry Schmitz 24-Jul-20 12:42pm    
You format the results of your query as a "string" (for example) and add it to the ".Text" (or whatever) property of whatever control is used to track the mouse. Draw a picture of your ui and visualize how the components should interact. Nobody gets it right if all they do is "think" about it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900