C#Zedgraph更改行短划线长度

Ash*_*lax 2 c# zedgraph line hyphen

我正在尝试在Zed Graph线上更改Dashes的长度.我希望实线之间有更大的间隙.

我的代码示例

LineItem LineCurve = null
LineCurve = ZedGraphControl.GraphPane.AddCurve("line1",PairPointListData, Color, Symbol);
//now I want to change the dash settings
LineCurve.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
LineCurve.Line.StepType = StepType.ForwardStep;
LineCurve.Line.DashOn = 1.0f;//Not sure what this floating point does
LineCurve.Line.DashOff = 1.0f;//Also not sure
Run Code Online (Sandbox Code Playgroud)

我已经改变了Dash On和Off的值,但我看不到任何明显的值.提前感谢任何建议/想法

Gor*_*ysz 7

您的短划线样式必须设置为"自定义".请参阅:http: //zedgraph.sourceforge.net/documentation/html/P_ZedGraph_LineBase_DashOff.htm

以下是一些示例代码:

        double[] xvals = new double[100];
        double[] yvals = new double[100];

        for (double i = 0; i < xvals.Length; i++)
        {
            xvals[(int)i] = i / 10;
            yvals[(int)i] = Math.Sin(i / 10);
        }

        var zgc = msGraphControl1.zedGraphControl1;
        var lineItem = zgc.GraphPane.AddCurve("Custom", xvals, yvals, Color.Blue);

        lineItem.Line.Style = DashStyle.Custom;
        lineItem.Line.Width = 3;
        lineItem.Line.DashOn = 5;
        lineItem.Line.DashOff = 10;

        //offset the next curve
        for (int i = 0; i < xvals.Length; i++)
        {
            xvals[i] = xvals[i] + 0.5;
            yvals[i] = yvals[i] + 0.05;
        }

        var lineItem2 = zgc.GraphPane.AddCurve("DashDotDot", xvals, yvals, Color.Red);

        lineItem2.Line.Width = 3;
        lineItem2.Line.Style = DashStyle.DashDotDot;

        //offset the next curve
        for (int i = 0; i < xvals.Length; i++)
        {
            xvals[i] = xvals[i] + 0.5;
            yvals[i] = yvals[i] + 0.05;
        }

        var lineItem3 = zgc.GraphPane.AddCurve("Solid", xvals, yvals, Color.Black);

        lineItem3.Line.Width = 3;
        lineItem3.Line.Style = DashStyle.Solid;


        zgc.AxisChange();
        zgc.Refresh();
Run Code Online (Sandbox Code Playgroud)