0
votes

I have fetch data of last 24 hours through stored procedure and I want to plot these data into Point chart. Result of the SP is

enter image description here

on X-Axis : LocationName..... on Y-axis : TrackTimeStamp

I have written following code for plotting point

 SqlConnection con = new SqlConnection(@"Data Source=10.182.37.210;Initial Catalog=ECSGCore_QA2;User Id=sa;pwd=sa@1234;");
            con.Open();
            SqlCommand cmd = new SqlCommand("Sp_GetAssetLocation",con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@AssetId", 32);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            chart1.DataSource = dt;
            chart1.ChartAreas["ChartArea1"].AxisX.Title = "Location";
            chart1.ChartAreas["ChartArea1"].AxisY.Title = "Time";
            //chart1.ChartAreas["ChartArea1"].AxisY.Minimum = 
            //chart1.ChartAreas["ChartArea1"].AxisY.Maximum = 
            //chart1.ChartAreas["ChartArea1"].AxisY.Interval = 
            chart1.Series["Series1"].XValueMember = "LocationName";
            chart1.Series["Series1"].YValueMembers = "TrackTimeStamp";
            con.Close();

And My result is :

enter image description here

My Questions :

  1. how to set minimum value like 0:00/12:00 AM and maximum value like 24:00/12:00 PM??
  2. I want to set interval of 2 hours starting from 12:00 AM to 12:00 PM. How it is possible?
  3. When I zoom in my chart interval should be change from 2 hour to 1 hour. Is it possible? How to complete my task?
  4. Location name should be distinct. "Eitra_FirstFloor_2" display 4 times.
  5. How to make link (hyperlink) of the point. on click event some another information shows.
1
You have tagged your question with win forms (which is mentioned in the question) and with three "asp.net"-related tags, which are not mentioned in the question. Some clarification is needed - Onkelborg
This question is for windows application not for web and we can set minimum value, maximum value and interval for our chart but this is only possible for decimal values. I don't know how to use use this property for time? I have mention my requirement in my questions. - RMR
I've removed the asp.net-related tags from the question now - Onkelborg

1 Answers

1
votes

In Charts time is represented as double, and the min (0:00) = 0.0, the max (24:00) = 1.0. Setting min and max:

chart1.ChartAreas[0].AxisX.Minimum = 0.7;

In this case the minX is set to cca 17:00 (17 / 24 = 0.7)

I believe that the interval is set in the same way