■ Pie 클래스의 BeforeDrawValues 이벤트를 사용해 복수 파이 차트를 만드는 방법을 보여준다.
▶ 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 |
using System.Drawing; using System.Windows.Forms; using Steema.TeeChart.Drawing; using Steema.TeeChart.Styles; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// 파이 1 /// </summary> private Pie pie1; /// <summary> /// 파이 2 /// </summary> private Pie pie2; /// <summary> /// 파이 3 /// </summary> private Pie pie3; /// <summary> /// 파이 4 /// </summary> private Pie pie4; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); Text = "Pie 클래스 : BeforeDrawValues 이벤트를 사용해 복수 파이 차트 만들기"; this.tChart.Aspect.ApplyZOrder = false; this.tChart.Panel.Pen = new ChartPen(Color.Black); this.tChart.Legend.Visible = false; this.pie1 = new Pie(); this.pie1.FillSampleValues(4); this.tChart.Series.Add(this.pie1); this.pie2 = new Pie(); this.pie2.FillSampleValues(4); this.tChart.Series.Add(this.pie2); this.pie3 = new Pie(); this.pie3.FillSampleValues(4); this.tChart.Series.Add(this.pie3); this.pie4 = new Pie(); this.pie4.FillSampleValues(4); this.tChart.Series.Add(this.pie4); this.pie1.BeforeDrawValues += pie1_BeforeDrawValues; this.pie2.BeforeDrawValues += pie2_BeforeDrawValues; this.pie3.BeforeDrawValues += pie3_BeforeDrawValues; this.pie4.BeforeDrawValues += pie4_BeforeDrawValues; } #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Private #region 파이 1 값 그리기 전 처리하기 - pie1_BeforeDrawValues(sender, graphics3D) /// <summary> /// 파이 1 값 그리기 전 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="graphics3D">그래픽스 3D</param> private void pie1_BeforeDrawValues(object sender, Graphics3D graphics3D) { this.tChart.Chart.ChartRect = new Rectangle ( 10, 10, this.tChart.Width / 2 - 20, this.tChart.Height / 2 - 20 ); } #endregion #region 파이 2 값 그리기 전 처리하기 - pie2_BeforeDrawValues(sender, graphics3D) /// <summary> /// 파이 2 값 그리기 전 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="graphics3D">그래픽스 3D</param> private void pie2_BeforeDrawValues(object sender, Graphics3D graphics3D) { this.tChart.Chart.ChartRect = new Rectangle ( this.tChart.Width / 2, 10, this.tChart.Width / 2 - 20, this.tChart.Height / 2 - 20 ); } #endregion #region 파이 3 값 그리기 전 처리하기 - pie3_BeforeDrawValues(sender, graphics3D) /// <summary> /// 파이 3 값 그리기 전 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="graphics3D">그래픽스 3D</param> private void pie3_BeforeDrawValues(object sender, Graphics3D graphics3D) { this.tChart.Chart.ChartRect = new Rectangle ( 10, this.tChart.Height / 2, this.tChart.Width / 2 - 20, this.tChart.Height / 2 - 20 ); } #endregion #region 파이 4 값 그리기 전 처리하기 - pie4_BeforeDrawValues(sender, graphics3D) /// <summary> /// 파이 4 값 그리기 전 처리하기 /// </summary> /// <param name="sender">이벤트 발생자</param> /// <param name="graphics3D">그래픽스 3D</param> private void pie4_BeforeDrawValues(object sender, Graphics3D graphics3D) { this.tChart.Chart.ChartRect = new Rectangle ( this.tChart.Width / 2, this.tChart.Height / 2, this.tChart.Width / 2 - 20, this.tChart.Height / 2 - 20 ); } #endregion } } |