SeriesList sList = new SeriesList();
sList.ChartType = ChartType.Spline;
sList.AxisFactor.XAxis.DataType = AxisDataType.Number;
Series sr = new Series();
sr.Points.Width = 0;
sr.Name = "x2 + 3x - 2";
Series sr2 = new Series();
sr2.Points.Width = 0;
sr2.Name = "3x - 1";
Series sr3 = new Series();
sr3.Points.Width = 0;
sr3.Name = "sinx";
sList.SeriesCollection.Add(sr);
sList.SeriesCollection.Add(sr2);
sList.SeriesCollection.Add(sr3);
int limit = 8;
for (int x = -1 * limit; x < limit; x++)
{
SeriesItem item = new SeriesItem();
item.XValue = x;
item.YValue = (float)(Math.Pow(x, 2) + 3 * x - 2);
if (x == 0)
{
item.Balloon = new Balloon();
item.Balloon.BalloonType = BalloonType.Rectangle;
item.Balloon.HeightType = HeightType.Bottom;
item.Balloon.BackColor = Color.White;
item.Balloon.Label.Text = "y = x2 + 3x - 2 y절편(" + item.YValue.ToString() + ")";
item.Points = new Points();
item.Points.Width = 6;
item.Points.PointType = PointType.FillCircle;
}
sList.SeriesCollection[0].items.Add(item);
}
for (int x = -1 * limit; x < limit; x++)
{
SeriesItem item = new SeriesItem();
item.XValue = x;
item.YValue = (float)(2 * x - 1);
if (x == 0)
{
item.Balloon = new Balloon();
item.Balloon.BalloonType = BalloonType.Rectangle;
item.Balloon.HeightType = HeightType.Bottom;
item.Balloon.BackColor = Color.White;
item.Balloon.Label.Text = "y = 3x - 1 y절편(" + item.YValue.ToString() + ")";
item.Points = new Points();
item.Points.Width = 6;
item.Points.PointType = PointType.FillCircle;
}
sList.SeriesCollection[1].items.Add(item);
}
for (int x = -1 * limit; x < limit; x++)
{
SeriesItem item = new SeriesItem();
item.XValue = x;
item.YValue = (float)(Math.Sin(x));
sList.SeriesCollection[2].items.Add(item);
}
// 기준 축 틱 표시
AxisTick tk = new AxisTick("0");
sList.AxisFactor.XAxis.Ticks.Add(tk);
sList.AxisFactor.YAxis.Ticks.Add(tk);
// 기준 축 라인 색 변경
sList.GraphArea.Grid.ZeroLineColor = Color.Black;
sList.AxisFactor.XAxis.IsAutoSetting = false;
sList.AxisFactor.XAxis.Interval = 1;
sList.AxisFactor.XAxis.MinUnitValue = -5;
sList.AxisFactor.XAxis.MaxUnitValue = 3;
sList.AxisFactor.YAxis.IsAutoSetting = false;
sList.AxisFactor.YAxis.Interval = 1;
sList.AxisFactor.YAxis.MinUnitValue = -5;
sList.AxisFactor.YAxis.MaxUnitValue = 2;
this.hHippoChart1.LegendBox.Location = LegendLocation.Top;
this.hHippoChart1.LegendBox.Header.NameLabel.Text = "함수의 그래프 식";
this.hHippoChart1.Titles.Label.Text = "함수의 그래프를 그려보자.";
this.hHippoChart1.Titles.Label.ForeColor = Color.SteelBlue;
this.hHippoChart1.DesignType = ChartDesignType.Simple;
this.hHippoChart1.SeriesListDictionary.Add(sList);
this.hHippoChart1.DrawChart(); |