3

在此处输入图像描述

有人可以告诉我如何在 MSChart 上显示 Total Collection

4

2 回答 2

4

您可以使用chart.Annotations属性来获得类似的结果。

例如使用以下代码(位于填充图表之后):

var ann = new RectangleAnnotation();
ann.Text = "Total Collection" + Environment.NewLine + "250 Billion";
ann.IsMultiline = true;
ann.AxisX = this.chart1.ChartAreas[0].AxisX;
ann.AxisY = this.chart1.ChartAreas[0].AxisY;
ann.AnchorX = 9;  // as you can see from the image below,
ann.AnchorY = 41; // these values are inside the range

// add the annotation to the chart annotations list
this.chart1.Annotations.Add(ann);

我得到以下结果:

在此处输入图像描述

注意:
有很多注解类型(CalloutAnnotation, EllipseAnnotation...),它们有很多属性可以改变样式和行为。您甚至可以设置一个属性以允许注释移动(即AllowMoving=true)。

通过智能感知或 MSDN 查看注释属性。

于 2012-08-05T08:13:56.257 回答
1

您可以将属性设置IsDockedInsideChartAreatrue。您还需要指定图例停靠到哪个 ChartArea,并将 position 属性设置为Auto

legend.IsDockedInsideChartArea = true;
legend.DockedToChartArea = "ChartArea1";

此处有关于此属性和其他图例属性的更多信息。

于 2013-06-26T17:41:52.167 回答