事实证明,这一切都比我想象的要简单得多……注释使用图表坐标。这意味着您所要做的就是对实际值求和并将其用作 y 坐标。我最终这样做是为了计算各个系列的高度:
private int CalculateHeight(int i, ChartGraphics graphics)
{
var height = 0.0;
// find the respective heights of series i, add them together
for (var x = 0; x < this.Chart1.Series.Count(); x++)
{
height += this.Chart1.Series[x].Points[i].YValues[0];
}
return (int)height;
}
然后我像这样调用该函数:
for (var i = 0; i < chart.Series[0].Points.Count(); i++ )
{
var height = this.CalculateHeight(i, e.ChartGraphics);
this.Chart1.Annotations[i].Y = height + verticalPadding;
}
比我想象的要简单得多。