Telerik WPF Legend 问题难住了
我需要动态生成图表,只有当我收到响应时,我才会知道要生成什么类型的图表。
我已经尝试了大约一个小时,但无法弄清楚。我做错了什么?图例显示标题,但不显示与每个数据点关联的图例标签。为什么?
我已经搜索了几个小时,并逐字记录了样本,但图例仍然不会显示 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";
I need to generate graphs on the fly and only when I receive the response will I know what type of graph to generate.
I have been trying for about a hour and cannot figure it out. What am I doing wrong? The legend shows the title, but it does not show the legend label that has been associated with each datapoint. Why?
I have searched for a few hours and I took there sample verbatim and still the legend will not show the LegendLabel. I started with the pie as I thought it would be the easiest.
What am I missing?
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";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前没有单独创建过数据点。但是,这是我用来将 DataView 中的信息分配给饼图的代码。它对我来说效果很好:
我在这里看到的差异是您将信息分配给 DataSeries 而不是 SeriesMappings。也许这会导致问题。
I have not created the DataPoints individually before. However, here is the code I use to assign information from a DataView to my pie chart. It works fine for me:
The differences I see here are that you are assigning the information to the DataSeries instead of the SeriesMappings. Maybe that causes an issue.