■ MomentumDivision 클래스를 사용해 이전 N 포인트 값과 비교한 포인트 값의 비율을 계산하는 방법을 보여준다.
▶ MainForm.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
using System; using System.Drawing; using System.Windows.Forms; using Steema.TeeChart; using Steema.TeeChart.Functions; using Steema.TeeChart.Tools; using Steema.TeeChart.Styles; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 라인 1 시리즈 /// </summary> private Line line1; /// <summary> /// 모멘텀 분할 함수 /// </summary> private MomentumDivision momentumDivision; /// <summary> /// 라인 2 시리즈 /// </summary> private Line line2; /// <summary> /// 색상 라인 /// </summary> private ColorLine colorLine; /// <summary> /// 축 /// </summary> private Axis axis; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); #region 축을 생성한다. this.axis = new Axis(); this.axis.StartPosition = 90d; this.axis.Title.Caption = "Mom. div."; this.axis.Title.Angle = 90; this.axis.LogarithmicBase = 2d; this.axis.TickOnLabelsOnly = false; #endregion #region 라인 1 시리즈를 생성한다. this.line1 = new Line(); this.line1.Title = "line1"; #endregion #region 모멘텀 분할 함수를 생성한다. this.momentumDivision = new MomentumDivision(); this.momentumDivision.Period = 1D; #endregion #region 라인 2 시리즈를 생성한다. this.line2 = new Line(); this.line2.Title = "line2"; this.line2.Brush.Color = Color.FromArgb(255, 207, 104); this.line2.Color = Color.FromArgb(255, 207, 104); this.line2.VertAxis = VerticalAxis.Custom; this.line2.CustomVertAxis = this.axis; this.line2.DataSource = this.line1; this.line2.Function = this.momentumDivision; #endregion #region 색상 라인을 생성한다. ColorLine colorLine1 = new ColorLine(); this.colorLine = new ColorLine(this.tChart.Chart); colorLine.Axis = this.tChart.Axes.Left; colorLine.Pen.Width = 2; colorLine.Pen.Color = Color.Red; #endregion #region 티차트를 설정한다. this.tChart.Panel.MarginLeft = 5; this.tChart.Axes.Left.EndPosition = 80; this.tChart.Axes.Left.Title.Angle = 90; this.tChart.Axes.Left.LogarithmicBase = 2d; this.tChart.Axes.Custom.Add(this.axis); this.tChart.Series.Add(this.line1); this.tChart.Series.Add(this.line2); #endregion this.line1.FillSampleValues(50); this.line2.CheckDataSource(); this.colorLine.Value = this.line1.YValues.Minimum; this.momentumDivision.Period = 10; this.periodNumericUpDown.ValueChanged += periodNumericUpDown_ValueChanged; this.periodNumericUpDown.TextChanged += periodNumericUpDown_TextChanged; this.showMomentumCheckBox.CheckedChanged += showMomentumCheckBox_CheckedChanged; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 기간 숫자 UP/DOWN 값 변경시 처리하기 - periodNumericUpDown_ValueChanged(sender, e) /// <summary> /// 기간 숫자 UP/DOWN 값 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void periodNumericUpDown_ValueChanged(object sender, EventArgs e) { this.momentumDivision.Period = (int)this.periodNumericUpDown.Value; } #endregion #region 기간 숫자 UP/DOWN 텍스트 변경시 처리하기 - periodNumericUpDown_TextChanged(sender, e) /// <summary> /// 기간 숫자 UP/DOWN 텍스트 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void periodNumericUpDown_TextChanged(object sender, EventArgs e) { this.momentumDivision.Period = (int)this.periodNumericUpDown.Value; } #endregion #region 모멘텀 표시 체크 박스 체크 변경시 처리하기 - showMomentumCheckBox_CheckedChanged(sender, e) /// <summary> /// 모멘텀 표시 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void showMomentumCheckBox_CheckedChanged(object sender, EventArgs e) { this.line2.Active = this.showMomentumCheckBox.Checked; if(this.line2.Active) { this.tChart.Axes.Left.EndPosition = 80; } else { this.tChart.Axes.Left.EndPosition = 100; } this.tChart.Axes.Custom[0].Visible = this.line2.Active; this.colorLine.Active = this.line2.Active; } #endregion } } |