时间:2019-05-17 标签:c#devexpresspichart系列点颜色变化

标签 c# colors devexpress pie-chart

我使用 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 事件,然后您可以使用其事件参数更改一些绘图参数。

检查这些事件以执行您的功能..

How to: Custom Paint Series Points

ChartControl.CustomDrawSeries Event

关于时间:2019-05-17 标签:c#devexpresspichart系列点颜色变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8385739/

相关文章:

ios - 更改 MFMailComposeViewController 的工具栏颜色

devexpress - DevExpress 中 LookupEdit 和 ComboBoxEdit 的区别

c# - 更改特定类型的所有控件的值而不会导致无限循环

c# - 在devexpress图表中找到两个系列的重叠点

c# - 从sql中解析对象

c# - iTextSharp。如何从 AcroFields 获取特定类型?像 PushButtonField、RadioCheckField 等

用于 C、C#、C++ 和 Java 的 C# 代码分析器。

javafx - 使用 slider 更改文本颜色

c# - 如何将输出值绑定(bind)到我的异步 Azure Functions?

colors - 通过 Composer 添加 Yii2 扩展