我需要即时生成图表,只有当我收到响应时,我才会知道要生成哪种类型的图表。
我已经尝试了大约一个小时,但无法弄清楚。我究竟做错了什么?图例显示标题,但不显示已与每个数据点关联的图例标签。为什么?
我已经搜索了几个小时,并且逐字逐句地拿了样本,但图例仍然不会显示 LegendLabel。我从馅饼开始,因为我认为它是最简单的。
我错过了什么?
var chartArea = new ChartArea();
chartArea.LegendName = "test";
var pieSeries = new DataSeries
{
Definition = new PieSeriesDefinition
{
InteractivitySettings =
{HoverScope = InteractivityScope.None,
SelectionScope = InteractivityScope.Item,
SelectionMode = ChartSelectionMode.Single
}
}
};
pieSeries.Definition.ItemLabelFormat = "p";
pieSeries.Add( new DataPoint() { YValue = 0.215208267, LegendLabel = "Toyota" } );
pieSeries.Add( new DataPoint() { YValue = 0.192960612, LegendLabel = "General Motors" } );
pieSeries.Add( new DataPoint() { YValue = 0.151830229, LegendLabel = "Volkswagen" } );
pieSeries.Add( new DataPoint() { YValue = 0.125964366, LegendLabel = "Ford" } );
pieSeries.Add( new DataPoint() { YValue = 0.091152353, LegendLabel = "Honda" } );
pieSeries.Add( new DataPoint() { YValue = 0.079093251, LegendLabel = "Nissan" } );
pieSeries.Add( new DataPoint() { YValue = 0.079093251, LegendLabel = "PSA" } );
pieSeries.Add( new DataPoint() { YValue = 0.064697675, LegendLabel = "Hyundai" } );
chartArea.DataSeries.Add(pieSeries);
RadChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
RadChart1.DefaultView.ChartArea = chartArea;
RadChart1.DefaultView.ChartLegend.Header = "Legend test";