locked
Setting Doughnut (or Pie) chart every datapoint color

    Question

  • I can't set every datapoint color of my Doughnut (or pie) chrt, it always show default color.

    Am I missing something? Or someone can tell me the code, thanks!

    (Develope enviroment is VB)

    Friday, December 19, 2008 2:23 AM

Answers

  •  Thank you! StuartLodge

    I am already try it success with a simple way.

    if pie chart have 3 part element...

    Chart1.Series("S1").Points(0).Color = System.Drawing.Color.Teal  
    Chart1.Series("S1").Points(1).Color = System.Drawing.Color.YellowGreen  
    Chart1.Series("S1").Points(2).Color = System.Drawing.Color.Khaki 
    • Marked as answer by JENOVA.H Tuesday, December 23, 2008 8:56 AM
    Tuesday, December 23, 2008 8:56 AM

All replies

  • Here's the code that worked for me:

            foreach (DataPoint p in series.Points)
            {
                Color colorToUse = colorToUse[i];
                p.Color = colorToUse;

                ChartHatchStyle hatchStyle = chartHatchStyleToUse[i];
                p.BackHatchStyle = hatchStyle;
            }

    where the two arrays are setup in my own code

    Hope that works for you too!

    (Sorry it's in c# - I'm a vb failure!)


    Stuart - geekie blog at http://slodge.blogspot.com
    • Proposed as answer by StuartLodge Friday, December 19, 2008 3:47 PM
    Friday, December 19, 2008 3:32 PM
  •  Thank you! StuartLodge

    I am already try it success with a simple way.

    if pie chart have 3 part element...

    Chart1.Series("S1").Points(0).Color = System.Drawing.Color.Teal  
    Chart1.Series("S1").Points(1).Color = System.Drawing.Color.YellowGreen  
    Chart1.Series("S1").Points(2).Color = System.Drawing.Color.Khaki 
    • Marked as answer by JENOVA.H Tuesday, December 23, 2008 8:56 AM
    Tuesday, December 23, 2008 8:56 AM