In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how C# can move the mouse and display data in the chart. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The details are as follows
Effect picture:
1. First add a label control to the page and hide it by default:
two。 Add a MouseMove mouse movement event to the chart:
/ private void chart1_MouseMove (object sender, MouseEventArgs e) {try {HitTestResult Result = new HitTestResult (); Result = chart1.HitTest (e.X, e.Y) If (Result.Series! = null & & Result.Object! = null) {/ / get the value of the x-axis of the current focus string xValue = ObjectUtil.GetPropertyValue (Result.Object, "AxisLabel") .ToString (); / / get the name of the area to which the current focus belongs, string areaName = ObjectUtil.GetPropertyValue (Result.Object, "LegendText"). ToString () / / get the value of the current focus y-axis double yValue = Result.Series.Points[ Result.PointIndex] .YValues [0]; / / label displays skinLabel4.Visible = "time: + xValue +"\ n "+ areaName +": "+ yValue +" ug/ m ^ 3 "; skinLabel4.Location = new Point (e.x, e.Y-20) } else {/ / label hides when the mouse leaves skinLabel4.Visible = false;}} catch (Exception se) {/ / label hides skinLabel4.Visible = false;} when the mouse leaves
3. Where GetPropertyValue () gets a property in the object as follows:
Public class ObjectUtil {/ public static object GetPropertyValue (object info, string field) {if (info = = null) return null; Type t = info.GetType (); IEnumerable property = from pi in t.GetProperties () where pi.Name.ToLower () = field.ToLower () select pi Return property.First () .GetValue (info, null);}
In addition (the following has nothing to do with the above) the chart binds the prompt after adding data:
/ Dust monitoring, noise monitoring, temperature monitoring, private void ChartTemperatureMethod monitoring / private void ChartTemperatureMethod (Chart _ Chart) {List xData = new List () {"0", "4:00", "8:00", "12:00", "16:00", "20:00", "24:00"}; List yData = new List () {0Jing 21, 35, 48, 40, 27, 7} List yData1 = new List () {0VALX 5, 18, 25, 68, 50, 30}; string iss = "# VALX"; / / Information to be prompted chart1.Series ["Series1"]. ToolTip = "time: # VALX\ nPM2.5:#VALYug/ m ^ 3\ tPM10:" + yData1 [xData.IndexOf ("# VALX") + 1] + "ug/ m ^ 3" / / tag shows Inside: internal, Outside: external, Disabled: disable chart1.Series ["Series1"] ["PieLabelStyle"] = "Outside"; chart1.Series ["Series1"] .Points.DataBindXY (xData, yData); / / Information to be prompted chart1.Series ["Series2"] .ToolTip = "time: # VALX\ nPM2.5:" + yData [xData.IndexOf ("# VALX") + 1] + "ug/ m3\ tPM10:#VALYug/ m ^ 3" / / tag shows Inside: internal, Outside: external, Disabled: disable chart1.Series ["Series2"] ["PieLabelStyle"] = "Outside"; chart1.Series ["Series2"] .Points.DataBindXY (xData, yData1) } this is the end of the article on "how to move the mouse and display data in the chart". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.