[C#/WINFORM/TEECHART] SeriesStats 클래스 : 시리즈 통계 사용하기
■ SeriesStats 클래스에서 시리즈 통계를 사용하는 방법을 보여준다. ▶ 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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
using System; using System.Drawing; using System.Windows.Forms; using Steema.TeeChart.Drawing; using Steema.TeeChart.Functions; using Steema.TeeChart.Styles; using Steema.TeeChart.Tools; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 소스 라인 /// </summary> private Line sourceLine; /// <summary> /// 시리즈 통계 /// </summary> private SeriesStats seriesStats; /// <summary> /// 평균 /// </summary> private Average average; /// <summary> /// 평균 라인 /// </summary> private Line averageLine; /// <summary> /// 추세 함수 /// </summary> private TrendFunction trendFunction; /// <summary> /// 추세 라인 /// </summary> private Line trendLine; /// <summary> /// 하한 /// </summary> private Low low; /// <summary> /// 하한 라인 /// </summary> private Line lowLine; /// <summary> /// 상한 /// </summary> private High high; /// <summary> /// 상한 라인 /// </summary> private Line highLine; /// <summary> /// 중위수 함수 /// </summary> private MedianFunction medianFunction; /// <summary> /// 중위수 라인 /// </summary> private Line medianLine; /// <summary> /// 상관 관계 함수 /// </summary> private CorrelationFunction correlationFunction; /// <summary> /// 상관 관계 라인 /// </summary> private Line correlationLine; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Text = "SeriesStats 클래스 : 시리즈 통계 사용하기"; this.averageCheckBox.Checked = true; this.tChart.Panel.Pen = new ChartPen(Color.Black); this.sourceLine = new Line(this.tChart.Chart); this.sourceLine.FillSampleValues(30); this.seriesStats = new SeriesStats(this.tChart.Chart); this.seriesStats.Series = this.sourceLine; this.average = new Average(this.tChart.Chart); this.averageLine = new Line(this.tChart.Chart); this.averageLine.LinePen.Width = 2; this.averageLine.Color = Color.Yellow; this.averageLine.DataSource = this.sourceLine; this.averageLine.Function = this.average; this.averageLine.Title = "평균"; this.averageLine.Active = true; this.trendFunction = new TrendFunction(); this.trendLine = new Line(this.tChart.Chart); this.trendLine.LinePen.Width = 2; this.trendLine.Color = Color.Blue; this.trendLine.DataSource = this.sourceLine; this.trendLine.Function = this.trendFunction; this.trendLine.Title = "추세선"; this.trendLine.Active = false; this.low = new Low(); this.lowLine = new Line(this.tChart.Chart); this.lowLine.LinePen.Width = 2; this.lowLine.Color = Color.Red; this.lowLine.DataSource = this.sourceLine; this.lowLine.Function = this.low; this.lowLine.Title = "하한"; this.lowLine.Active = false; this.high = new High(); this.highLine = new Line(this.tChart.Chart); this.highLine.LinePen.Width = 2; this.highLine.Color = Color.Red; this.highLine.DataSource = this.sourceLine; this.highLine.Function = this.high; this.highLine.Title = "상한"; this.highLine.Active = false; this.medianFunction = new MedianFunction(this.tChart.Chart); this.medianLine = new Line(this.tChart.Chart); this.medianLine.LinePen.Width = 2; this.medianLine.Color = Color.Gray; this.medianLine.DataSource = this.sourceLine; this.medianLine.Function = this.medianFunction; this.medianLine.Title = "중위수"; this.medianLine.Active = false; this.correlationFunction = new CorrelationFunction(); this.correlationLine = new Line(this.tChart.Chart); this.correlationLine.LinePen.Width = 2; this.correlationLine.Color = Color.Magenta; this.correlationLine.DataSource = this.sourceLine; this.correlationLine.Function = this.correlationFunction; this.correlationLine.Title = "상관 관계"; this.correlationLine.Active = false; this.averageCheckBox.CheckedChanged += averageCheckBox_CheckedChanged; this.trendCheckBox.CheckedChanged += trendCheckBox_CheckedChanged; this.lowCheckBox.CheckedChanged += lowCheckBox_CheckedChanged; this.highCheckBox.CheckedChanged += highCheckBox_CheckedChanged; this.mediumCheckBox.CheckedChanged += mediumCheckBox_CheckedChanged; this.correlationCheckBox.CheckedChanged += correlationCheckBox_CheckedChanged; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 평균 체크 박스 체크 변경시 처리하기 - averageCheckBox_CheckedChanged(sender, e) /// <summary> /// 평균 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void averageCheckBox_CheckedChanged(object sender, EventArgs e) { this.averageLine.Active = this.averageCheckBox.Checked; } #endregion #region 추세선 체크 박스 체크 변경시 처리하기 - trendCheckBox_CheckedChanged(sender, e) /// <summary> /// 추세선 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void trendCheckBox_CheckedChanged(object sender, EventArgs e) { this.trendLine.Active = this.trendCheckBox.Checked; } #endregion #region 하한 체크 박스 체크 변경시 처리하기 - lowCheckBox_CheckedChanged(sender, e) /// <summary> /// 하한 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void lowCheckBox_CheckedChanged(object sender, EventArgs e) { this.lowLine.Active = this.lowCheckBox.Checked; } #endregion #region 상한 체크 박스 체크 변경시 처리하기 - highCheckBox_CheckedChanged(sender, e) /// <summary> /// 상한 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void highCheckBox_CheckedChanged(object sender, EventArgs e) { this.highLine.Active = this.highCheckBox.Checked; } #endregion #region 중위수 체크 박스 체크 변경시 처리하기 - mediumCheckBox_CheckedChanged(sender, e) /// <summary> /// 중위수 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void mediumCheckBox_CheckedChanged(object sender, EventArgs e) { this.medianLine.Active = this.mediumCheckBox.Checked; } #endregion #region 상관 관계 체크 박스 체크 변경시 처리하기 - correlationCheckBox_CheckedChanged(sender, e) /// <summary> /// 상관 관계 체크 박스 체크 변경시 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="e">이벤트 인자</param> private void correlationCheckBox_CheckedChanged(object sender, EventArgs e) { this.correlationLine.Active = this.correlationCheckBox.Checked; } #endregion } } |
TestProject.zip