1

我刚刚开始使用 DevExpress 图表组件,我正在尝试一个饼图。

它工作正常,但我有一个问题,即使它可能很简单,我也无法在任何地方找到答案。

图例显示了百分比,但我需要它来显示“ArgumentDataMember”,否则图例并没有真正的帮助。

这是短代码:

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

    chartControl.Series.Add(series1);

    series1.DataSource = dt;
    series1.ArgumentScaleType = ScaleType.Qualitative;
    series1.ArgumentDataMember = "CategoryName";
    series1.ValueScaleType = ScaleType.Numerical;
    series1.ValueDataMembers.AddRange(new string[] { "Products" });
    series1.LegendText = series1.ArgumentDataMember;
    chartControl.Legend.Visible = true;

显然 series1.LegendText = series1.ArgumentDataMember; 没用。

有人知道如何将参数(数据名称)用作图例文本而不是值吗?

4

3 回答 3

1

您可以通过以下代码与 LegendPointOptions 一起使用:

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

chartControl.Series.Add(series1);

series1.DataSource = dt;
series1.ArgumentScaleType = ScaleType.Qualitative;
series1.ArgumentDataMember = "CategoryName";
series1.ValueScaleType = ScaleType.Numerical;
series1.ValueDataMembers.AddRange(new string[] { "Products" });
series1.LegendText = series1.ArgumentDataMember;

series1.LegendPointOptions.Pattern = string.Concat("{V}");//or string.Concat("{A}") or string.Concat("{A}:{V}")

chartControl.Legend.Visible = true;
于 2014-05-12T11:32:56.520 回答
1
 Series series1 = new Series("Series1", ViewType.Pie3D);

    chartControl.Series.Add(series1);

    series1.DataSource = dt;
    series1.ArgumentScaleType = ScaleType.Qualitative;
    series1.ArgumentDataMember = "CategoryName";
    series1.ValueScaleType = ScaleType.Numerical;
    series1.ValueDataMembers.AddRange(new string[] { "Products" });
   // series1.LegendText = series1.ArgumentDataMember;
   series1.PointOptions.PointView = PointView.Argument; //this is code that you want
  //if you only legend box change
  series1.LegendPointOptions.PointView = PointView.Argument;
    chartControl.Legend.Visible = true;
于 2013-05-27T02:52:25.463 回答
0

您可以将属性设置为 false。

CType(series.PointOptions, PiePointOptions).PercentOptions.ValueAsPercent = False

Vb.NET 示例。

For Each series As Series In ChartControl1.Series
     If series.PointOptions.GetType = GetType(PiePointOptions) Then
          CType(series.PointOptions, PiePointOptions).PercentOptions.ValueAsPercent = False
          series.ShowInLegend = True
     End If
     series.PointOptions.ValueNumericOptions.Format = NumericFormat.Number
     series.PointOptions.ValueNumericOptions.Precision = 1
Next
于 2014-11-20T18:25:16.990 回答