我使用 devexpress 制作了动态 3D 饼图。其良好的控制功能给我留下了深刻的印象。不过我还是有点沮丧。 我希望我的饼图点具有我在代码中设置的不同颜色(用户稍后将使用某种形式的托盘或组合框进行更改,目前还不确定)。不幸的是,我似乎无法获得数据系列点的颜色方法。
这是排除大量注释掉的尝试的代码:
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;
所以我需要像chartcontrol2.series1.point[0].color = color.blue;这样的东西像这样的东西。
最佳答案
在绘制图表的系列点时绘制图表。为此,您应该处理 ChartControl.CustomDrawSeriesPoint 事件,然后您可以使用其事件参数更改一些绘图参数。
检查这些事件以执行您的功能..
关于时间:2019-05-17 标签:c#devexpresspichart系列点颜色变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8385739/