滑鼠移動到曲線圖上顯示值

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   os   ar   使用   sp   

 完成折線圖報表後,產品經理要求把折線上的數值去掉,滑鼠經過折線點時顯示數值,實現方法如下: 該方法針對dotnetcharting 下的charting折線圖報表使用。 實現思路,在該表單上添加一個lable標籤,當滑鼠經過折線點時擷取該點的x軸,y軸值和滑鼠座標值。然後將lable的座標標記為滑鼠所在座標,並且給lable賦值,並且將lable顯示出來。      /// <summary>        /// 滑鼠移動到曲線圖上顯示值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void chart4_MouseMove(object sender, MouseEventArgs e)        {            var chart = sender as Chart;            if (chart != null)            {                HitTestInfo hit = chart.HitTest(e.X, e.Y);                var o = hit.Object as Element;                if (o != null)                {                    var yvaule = o.YValue;                    label2.Visible = true;//滑鼠經過時label顯示                    label2.Text = yvaule.ToString(CultureInfo.InvariantCulture);                    label2.Location = new Point(e.X, e.Y - 20);                }                else//滑鼠離開時lable隱藏                {                    label2.Visible = false;                }            }        } 折線圖和其他報表的產生可參考  dotnetcharting 的簡單使用

滑鼠移動到曲線圖上顯示值

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.