我刚刚开始使用DevExpress Charting Components,我正在尝试一个饼图。
它工作正常,但我有一个问题,我无法在任何地方找到答案,即使它可能很简单。
传奇显示百分比,但我需要它来显示“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;
显然是seri1.LegendText = series1.ArgumentDataMember;没用。
有人知道如何使用参数(数据名称)作为图例文本而不是值吗?
答案 0 :(得分: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;
答案 1 :(得分: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;
答案 2 :(得分: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