amit patel
amit patel

Reputation: 2297

how can i apply different color to datapoint of ms chart?

I am working on MS chart, not having so much idea.

I have bind the chart, my next thing is to give different colors of each datapoint?

How can i do that?

My sample code is:

 foreach (DataPoint pt in ChartRTM.Series["SeriesSeverity"].Points)
 {
      string sev = pt.YValues[1].ToString(); // this will be your value depending upon which you could set the color
      switch (sev)
      {
           case "I":
                pt.Color = Color.Red;
                break;
           default:
                pt.Color = Color.Blue;
                break;
      }
 }

enter image description here

Upvotes: 1

Views: 2246

Answers (1)

Larry
Larry

Reputation: 18031

I think you want to change the Marker color of the point :

To do this, change the switch statement :

switch (sev) 
{ 
     case "I": 
          pt.MarkerColor = Color.Red; 
          break; 
     default: 
          pt.MarkerColor = Color.Blue; 
          break; 
} 

Upvotes: 1

Related Questions