【问题标题】:How to create dashline C# graph如何创建虚线 C# 图
【发布时间】:2014-05-15 23:08:43
【问题描述】:

我正在尝试为图表添加一条虚线,但它一直显示为实线。我该如何解决?

static public NPlot.Bitmap.PlotSurface2D getDashlineGraph(int itemID, int width, int height)
{
    NPlot.Bitmap.PlotSurface2D plot = new NPlot.Bitmap.PlotSurface2D(width, height);
    plot.BackColor = Color.WhiteSmoke;
    plot.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

    LinePlot TotaldashLine = new LinePlot(straightline, timer);     
    float[] pattern = { 5.0f, 10.0f };
    TotaldashLine.Pen = new Pen(Color.Green,0.5f);
    TotaldashLine.Pen.DashPattern = pattern;       
    plot.Add(TotaldashLine, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Right, 100);

    Grid oGrid = new Grid();
    oGrid.HorizontalGridType = Grid.GridType.Coarse;
    oGrid.VerticalGridType = Grid.GridType.Coarse;
    plot.Add(oGrid);       
     plot.Refresh();
    return plot;

}

【问题讨论】:

    标签: c# .net graph plot gdi+


    【解决方案1】:

    您需要指定您希望您的Pen 使用Pen.DashStyle 绘制虚线:

    TotaldashLine.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
    

    完成此操作后,您还可以使用 Pen.DashPattern 自定义破折号和间隙的长度。

    【讨论】:

      猜你喜欢
      • 2017-11-10
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多