첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

■ 커스텀 그리기

----------------------------------------------------------------------------------------------------


TestProject.zip


MainForm.cs

 

 

using System;

using System.Drawing;

using System.Drawing.Drawing2D;

using System.Windows.Forms;

 

using Steema.TeeChart.Drawing;

using Steema.TeeChart.Styles;

 

namespace TestProject

{

    /// <summary>

    /// 메인 폼

    /// </summary>

    public partial class MainForm : Form

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainForm()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainForm()

        {

            InitializeComponent();

 

            Load += Form_Load;

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

        //////////////////////////////////////////////////////////////////////////////// Event

 

        #region 폼 로드시 처리하기 - Form_Load(sender, e)

 

        /// <summary>

        /// 폼 로드시 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="e">이벤트 인자</param>

        private void Form_Load(object sender, EventArgs e)

        {

            this.tChart.Aspect.View3D = false;

 

            this.tChart.AfterDraw += tChart_AfterDraw;

 

            Line line = new Line(this.tChart.Chart);

 

            line.HorizAxis = HorizontalAxis.Both;

            line.VertAxis  = VerticalAxis.Both;

 

            line.FillSampleValues(20);

        }

        

        #endregion

        #region 티차트 그리기 후 처리하기 - tChart_AfterDraw(sender, graphics3D)

 

        /// <summary>

        /// 티차트 그리기 후 처리하기

        /// </summary>

        /// <param name="sender">이벤트 발생자</param>

        /// <param name="graphics3D">이벤트 인자</param>

        private void tChart_AfterDraw(object sender, Graphics3D graphics3D)

        {

            if(this.tChart.Series.Count > 0)

            {

                if(this.tChart.Series[0].Count > 10)

                {

                    Series series = this.tChart.Series[0];

                    

                    int   characterHeight = Convert.ToInt32(graphics3D.TextHeight("H"));

                    Point startPoint      = new Point(series.CalcXPos(3 ), series.CalcYPos(3 ));

                    Point endPoint        = new Point(series.CalcXPos(10), series.CalcYPos(10));

 

                    graphics3D.Pen.Style = DashStyle.Dash;

                    graphics3D.Pen.Color = Color.Blue;

                    graphics3D.Pen.Width = 2;

 

                    graphics3D.MoveTo(startPoint);

                    graphics3D.LineTo(endPoint, 0);

 

                    graphics3D.TextOut(startPoint.X, startPoint.Y - characterHeight, "Point value : " + series.YValues[3].ToString());

 

                    graphics3D.TextOut(endPoint.X, endPoint.Y, "Point value : " + series.YValues[10].ToString());

 

                    graphics3D.TextOut(endPoint.X, endPoint.Y + characterHeight, "Change is : " +

                        Convert.ToString(series.YValues[3] - series.YValues[10]));

                }

            }

        }

 

        #endregion

    }

}

 

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker
TAG

댓글을 달아 주세요