用C#繪製曲線圖(Curve圖,增加自動適應和多曲線繪製)

來源:互聯網
上載者:User

在N久之前,我發過一個繪製曲線的文章 先發個繪製曲線圖的:用ASP.NET with C# 繪製曲線圖 (Curve圖) 裡面介紹了簡單的繪製曲線圖的方法.近來重新翻閱了這篇文章.心情大好之下又重新修改了 一下繪製方法,增加自動適應資料的處理和可以根據傳入的資料繪製多條曲線

照例先上圖:

比以前Cool吧?呵呵,其實就是根據資料自動計算邊距和字型等.

/// <summary>        /// 自動根據參數調整映像大小        /// </summary>        public void Fit()        {            //計算字型距離            intFontSpace = FontSize + 5;            //計算映像邊距            float fltSpace = Math.Min(Width / 6, Height / 6);            XSpace = fltSpace;            YSpace = fltSpace;            //計算X軸刻度寬度            XSlice = (Width - 2 * XSpace) / (Keys.Length - 1);            //計算Y軸刻度寬度和Y軸刻度開始值            float fltMinValue = 0;            float fltMaxValue = 0;            for (int i = 0; i < Values.Length; i++)            {                if (Values[i] < fltMinValue)                {                    fltMinValue = Values[i];                }                else if (Values[i] > fltMaxValue)                {                    fltMaxValue = Values[i];                }            }            if (YSliceBegin > fltMinValue)            {                YSliceBegin = fltMinValue;            }            int intYSliceCount = (int)(fltMaxValue / YSliceValue);            if (fltMaxValue % YSliceValue != 0)            {                intYSliceCount++;            }            YSlice = (Height - 2 * YSpace) / intYSliceCount;        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.