Farhan Shariff

Farhan Shariff

  • NA
  • 933
  • 241.6k

How to change colors of specific data points in a graph

Apr 3 2014 5:50 AM

Chart chart1 = new Chart();

           chart1.Width = 1600;

           chart1.Height = 900;

         

           Series Series1 = new Series();

           Series Series2 = new Series();

            Series1.Name = "Series1";

          

 

           Series1.ChartType = SeriesChartType.Line;

           Series1.BorderDashStyle = ChartDashStyle.Solid;

           Series1.BorderWidth = 1;

           Series1.ShadowColor = Color.FromArgb(128, 128, 128);

       

 

 

            chart1.Series.Add(Series1);

 

         

  //create chartareas...

            ChartArea ca = new ChartArea();

            ca.Name = "ChartArea1";

            ca.BackColor = Color.White;

            ca.BorderDashStyle = ChartDashStyle.Solid;

            ca.AxisX = new Axis();

            ca.AxisY = new Axis();

 

 

             chart1.ChartAreas.Add(ca);

    

   chart1.Series["Series1"].Points.DataBindXY(ds.Tables[0].DefaultView,table8.Columns[0].ColumnName, ds.Tables[0].DefaultView, "plot");

 

  chart1.ChartAreas[0].AxisY.Minimum = 0;

  chart1.ChartAreas[0].AxisY.Maximum = 1;

  ca.AxisY.IntervalOffset = 0.1;

 

  chart1.Series(1).Points(0).Color = Color.Red;

 

//Error

/*

Non-invocable member 'System.Windows.Forms.DataVisualization.Charting.Chart.Series' cannot be used like a method.       

*/


Answers (11)