2

我正在尝试更改 Zed Graph 线上破折号的长度。我希望实线之间有更大的间隙。

我的代码示例

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

我已经更改了 Dash On 和 Off 的值,但我看不到任何明显的东西。

4

1 回答 1

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();
于 2012-05-09T16:50:42.353 回答