【问题标题】:c# devexpress piechart series point color change时间:2019-05-10 标签:c#devexpress饼图系列点颜色变化
【发布时间】:2011-12-05 13:03:37
【问题描述】:

我使用 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;像这样的。

【问题讨论】:

  • 你试过Series1.point[0].Color Series1.point[1].Color ..so on
  • 是的,series1.point[] 没有颜色方法

标签: c# colors devexpress pie-chart


【解决方案1】:

在绘制图表的系列点时绘制图表。为此,您应该处理 ChartControl.CustomDrawSeriesPoint 事件,然后您可以使用其事件 args 更改一些绘图参数。

检查这些事件以完成您的功能..

How to: Custom Paint Series Points

ChartControl.CustomDrawSeries Event

【讨论】:

    【解决方案2】:

    您需要定义一个图表 Palette 或使用 DevExpress 定义的现有图表。看到这个

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

    【讨论】:

      猜你喜欢
      • 2020-06-15
      • 2020-10-01
      • 2015-06-14
      • 2011-07-08
      • 2012-02-03
      • 2017-04-15
      • 2021-07-31
      • 2016-01-27
      • 1970-01-01
      相关资源
      最近更新 更多