如何使条纹线出现在图表数据点上

本文关键字:数据 何使条 | 更新日期: 2023-09-27 18:01:39

我有一个微软图表控件,我使用StripLine。如何让StripLine出现在数据点的前面。目前条带线隐藏在一些数据后面。

如何使条纹线出现在图表数据点上

据我所知,StripLine总是画在数据点后面。然而,解决这个问题的一种方法是使用PostPaint事件处理程序并自己绘制矩形。

在处理程序中,你可以得到如下的绘图坐标

private void chart_PostPaint(object sender, ChartPaintEventArgs e)
{
  ChartArea a = sender as ChartArea;
  if (a != null)
  {
    Gaphics g = e.ChartGrpahics.Graphics;
    RectangleF r = e.ChartGraphics.GetAbsoluteRectangle(new RectangleF(0,0,10,50)); // the rect you need
    g.FillRectangle(new Brushes.Yellow, r);
  }
}