RR
Ramya R
Syncfusion Team
March 15, 2007 11:29 AM UTC
Hi Satishkumar,
If your intention is to draw a TrendLine for a scatter chart then the trendline can be drawn only continuously without any gap since the trend lines are used to identify the slope taking all points of scatter into account. Kindly take a look at the attached sample.
You can download the sample from the Webpage link given below,
http://websamples.syncfusion.com/samples/Chart.Windows/F57974/main.htm
Or if your intention is drawlines with gap just interesecting the ScatterChart then it can be done as shown in the code snippet below,
private void Form1_Load(object sender, EventArgs e)
{
IntializeChartData();
DrawlineforScatter();
}
private void DrawlineforScatter()
{
ChartSeries ser = this.chartControl1.Model.NewSeries("Series1", ChartSeriesType.Line);
ser.Points.Add(1, 6);
ser.Points.Add(2, 7);
ser.Points.Add(3, 8);
ser.Points.Add(4, 9);
ser.Points.Add(5, 10);
ser.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Blue);
this.chartControl1.Series.Add(ser);
ChartSeries ser1 = this.chartControl1.Model.NewSeries("Series2", ChartSeriesType.Line);
ser1.Points.Add(6, 11);
ser1.Points.Add(7, 12);
ser1.Style.Interior = new Syncfusion.Drawing.BrushInfo(Color.Blue);
this.chartControl1.Series.Add(ser1);
}
private void IntializeChartData()
{
//Creates a new series
ChartSeries series1 = this.chartControl1.Model.NewSeries("Birds Age Record", ChartSeriesType.Scatter);
series1.Text = series1.Name;
//Add method is used to add points to the series
series1.Points.Add(1, 6);//series1.Points.Add(Xvalue,Yvalue)
series1.Points.Add(2, 7);
series1.Points.Add(3, 8);
series1.Points.Add(4, 9);
series1.Points.Add(5, 10);
series1.Points.Add(6, 11);
series1.Points.Add(7, 12);
//Series created is added to the chartcontrol
this.chartControl1.Series.Add(series1);
this.chartControl1.Series[0].Style.Symbol.Color = Color.Orange;
//To set the Range of PrimaryYAxis
this.chartControl1.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
//Range of PrimaryYAxis
this.chartControl1.PrimaryYAxis.Range = new MinMaxInfo(0, 15, 2);
//Title to be displayed along PrimaryXAxis
this.chartControl1.PrimaryXAxis.Title = "Size of Wings of a Bird";
//Title to be displayed along PrimaryYAxis
this.chartControl1.PrimaryYAxis.Title = "Age in Days";
//Visibility of Grid of PrimaryXAxis and PrimaryYAxis
this.chartControl1.PrimaryXAxis.DrawGrid = false;
this.chartControl1.PrimaryYAxis.DrawGrid = false;
this.chartControl1.PrimaryXAxis.ForeColor = Color.Green;
this.chartControl1.PrimaryYAxis.ForeColor = Color.Green;
}
Let me know if I am wrong in getting your requirement.
If I am wrong in getting you, could you also please provide me with some screenshots regarding your requirement so that it would help me to meet your requirement exactly.
Thanks & Regards,
Ramya.