Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当选定切片=真时,在饼图上查看#VAL标签,而不是在序列内部_C#_Winforms_Visual Studio_.net 3.5_Mschart - Fatal编程技术网

C# 当选定切片=真时,在饼图上查看#VAL标签,而不是在序列内部

C# 当选定切片=真时,在饼图上查看#VAL标签,而不是在序列内部,c#,winforms,visual-studio,.net-3.5,mschart,C#,Winforms,Visual Studio,.net 3.5,Mschart,我用mschart创建了一个饼图,现在,我已经对填充的数据进行了硬编码。当选择一个切片时,我希望显示一个标签来显示该值-它现在执行此操作,但是以及在图表上显示(正确),在系列中显示(不正确) 伪码 我有两种方法-MouseDown和MouseMove:(#百分比工具提示效果很好) 填充图表数据时,只需使用DataPoint的LegendText属性: PieChart.Series[0].Points.Add(new DataPoint(1, 1) { LegendText = "aaa" }

我用mschart创建了一个饼图,现在,我已经对填充的数据进行了硬编码。当选择一个切片时,我希望显示一个标签来显示该值-它现在执行此操作,但是以及在图表上显示(正确),在系列中显示(不正确)

伪码 我有两种方法-MouseDownMouseMove:(#百分比工具提示效果很好)


填充图表数据时,只需使用DataPoint的
LegendText
属性:

PieChart.Series[0].Points.Add(new DataPoint(1, 1) { LegendText = "aaa" });
PieChart.Series[0].Points.Add(new DataPoint(1, 2) { LegendText = "bbb" });
PieChart.Series[0].Points.Add(new DataPoint(1, 3) { LegendText = "ccc" });
另一种方法是每次设置标签时设置
LegendText

point.Label = "Value: #VAL";
point.LegendText = "Series#INDEX"; // Or whatever you want

我已经尝试过你的解决方案,但都不起作用:/请参阅更新的问题。如果选择了数据点或图例(在方法注释中),我将MouseDown方法中的两个代码位都放在该方法中。第一个代码位不应放在
MouseDown
事件中。在向图表添加新点时应该使用它。我已经为您创建了示例项目:我尝试了示例项目,看起来效果不错。添加的点应为项目中所示的形式。如果你把鼠标放在里面,那么每一个鼠标放下来你都会创造一个新的点,这就是为什么你有这么多的传奇谢谢!好长时间我都没办法控制它!
PieChart.Series[0].Points.Add(new DataPoint(1, 1) { LegendText = "aaa" });
point.Label = "Value: #VAL";
point.LegendText = "Series#INDEX";
PieChart.Series[0].Points.Add(new DataPoint(1, 1) { LegendText = "aaa" });
PieChart.Series[0].Points.Add(new DataPoint(1, 2) { LegendText = "bbb" });
PieChart.Series[0].Points.Add(new DataPoint(1, 3) { LegendText = "ccc" });
point.Label = "Value: #VAL";
point.LegendText = "Series#INDEX"; // Or whatever you want