轴文本未打印,坐标未被绘制

时间:2014-05-23 14:08:48

标签: c# .net zedgraph

以下代码仅显示标准图形,但不会打印轴文本,也不会绘制任何坐标。

public void JapaneseCandleStick()
{
    //GraphPane myPane = base.GraphPane;

    GraphPane myPane = new GraphPane();

    myPane.Title.Text = "Japanese Candlestick Chart Demo";
    myPane.XAxis.Title.Text = "Trading Date";
    myPane.YAxis.Title.Text = "Share Price, $US";

    StockPointList spl = new StockPointList();
    Random rand = new Random();

    // First day is jan 1st
    XDate xDate = new XDate(2006, 1, 1);
    double open = 50.0;

    for (int i = 0; i < 50; i++)
    {
        double x = xDate.XLDate;
        double close = open + rand.NextDouble() * 10.0 - 5.0;
        double hi = Math.Max(open, close) + rand.NextDouble() * 5.0;
        double low = Math.Min(open, close) - rand.NextDouble() * 5.0;

        StockPt pt = new StockPt(x, hi, low, open, close, 100000);
        spl.Add(pt);

        open = close;
        // Advance one day
        xDate.AddDays(1.0);
        // but skip the weekends
        if (XDate.XLDateToDayOfWeek(xDate.XLDate) == 6)
            xDate.AddDays(2.0);
    }

    JapaneseCandleStickItem myCurve = myPane.AddJapaneseCandleStick("trades", spl);
    myCurve.Stick.IsAutoSize = true;
    myCurve.Stick.Color = Color.Blue;

    // Use DateAsOrdinal to skip weekend gaps
    myPane.XAxis.Type = AxisType.DateAsOrdinal;

    // pretty it up a little
    myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f);
    myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f);

    zedGraphControl1.AxisChange();
    //base.ZedGraphControl.AxisChange();
}

上面有什么问题,为什么我看不到任何文字或看到情节?这一切都编译没有错误,因此引用和ZedGraph实现/引用似乎是有序的。

1 个答案:

答案 0 :(得分:0)

当您创建Graphpane实例时,必须引用zedGraphControl1,使用以下代码行:

 GraphPane myPane = zedGraphControl1.GraphPane; 

&安培;这是输出:

enter image description here