lemunk
lemunk

Reputation: 2636

c# devexpress piechart series point color change

I've made a dynamic 3d piechart using devexpress. I'm really impressed with how good the control feature is. I've hit a little bit of a downer though. I would like my pie chart points to have different colors that I set in code (this will later be changed by the user using some form of pallet or combo box, not sure yet). Unfortunatly I can't seem to get a color method for the points of my data series.

Here's the code excluding the mass of commented out attempts:

Series series1 = new Series("Series1", ViewType.Pie3D);

        chartControl2.Series.Add(series1);

        series1.DataSource = chartTable;
        series1.ArgumentScaleType = ScaleType.Qualitative;
        series1.ArgumentDataMember = "names";
        series1.ValueScaleType = ScaleType.Numerical;
        series1.ValueDataMembers.AddRange(new string[] { "Value" });

        //series1.Label.PointOptions.PointView = PointView.ArgumentAndValues;
        series1.LegendPointOptions.PointView = PointView.ArgumentAndValues;
        series1.LegendPointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
        series1.LegendPointOptions.ValueNumericOptions.Precision = 0;

        // Adjust the value numeric options of the series.
        series1.Label.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
        series1.Label.PointOptions.ValueNumericOptions.Precision = 0;

        // Adjust the view-type-specific options of the series.
        ((Pie3DSeriesView)series1.View).Depth = 20;
        ((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[0]);
        ((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[1]);
        ((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[2]);
        ((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[3]);
        ((Pie3DSeriesView)series1.View).ExplodedDistancePercentage = 20;

        chartControl2.Legend.Visible = true;

So I need something like chartcontrol2.series1.point[0].color = color.blue; something like this.

Upvotes: 2

Views: 10009

Answers (2)

Niranjan Singh
Niranjan Singh

Reputation: 18290

Drawing in charts when drawing the series points of charts. To do this you should handle the ChartControl.CustomDrawSeriesPoint event, and then you can change some of the drawing parameters using its event args.

check these events to do your functinality..

How to: Custom Paint Series Points

ChartControl.CustomDrawSeries Event

Upvotes: 4

Azhar Khorasany
Azhar Khorasany

Reputation: 2709

You need to define a chart Palette or use an existing one defined by DevExpress. See this

http://documentation.devexpress.com/#XtraCharts/CustomDocument7434

Upvotes: 0

Related Questions