How to make StripLine appear over chart data points

孤街浪徒 提交于 2019-12-24 05:55:08

问题


I have a microsoft chart control and I use a StripLine. How do I make the StripLine appear in front of the data points. Currently the strip line is hidden behind some data. The chart is an area chart.


回答1:


As far as I'm aware StripLine will always be drawn behind the data points. One way to fudge this howerver would be to use a PostPaint event handler and draw the rectangle yourself.

inside the handler your can get drawing coordinates as follows

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);
  }
}


来源:https://stackoverflow.com/questions/23473260/how-to-make-stripline-appear-over-chart-data-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!