c# devexpress piechart series point color change

依然范特西╮ 提交于 2020-01-04 13:50:20

问题


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.


回答1:


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




回答2:


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

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



来源:https://stackoverflow.com/questions/8385739/c-sharp-devexpress-piechart-series-point-color-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!