谁能告诉我如何在 MSChart 上显示 Total Collection
最佳答案
您可以使用 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 查看注释属性。
关于图表区域内的 MSchart 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11717478/