graphobject走出ZedGraph Axis框架

时间:2012-02-01 10:05:17

标签: c# .net zedgraph

我正在开发一种自定义射频分析仪,我必须使用ZedGraph将无线电数据包绘制为矩形。工作几乎完成,图表工作正常,但我面临的问题是:(1)矩形走出轴框架(2)鼠标光标显示总共3个值,但我只需要显示(x,y)值。这是代码:

    private void CreateGraph(ZedGraphControl zgc)
    {

        GraphPane myPane = zgc.GraphPane;            
        myPane.Title.IsVisible = false;
        myPane.XAxis.Title.Text = "Time(Mili-Seconds)";                   

        if (isStartPoint)
        {                
            startPoint = PacketHandler.getFirstPoint();               
            myPane.XAxis.Scale.Min = startPoint;

            myPane.XAxis.Scale.MaxAuto = true;
            myPane.XAxis.Scale.MajorStep=100;
            myPane.XAxis.Scale.MinorStep=100;

            myPane.YAxis.IsVisible = false;
            myPane.YAxis.Title.IsVisible = false; 
            myPane.YAxis.Scale.MinAuto=true;
            myPane.YAxis.Scale.MaxAuto = true;
            myPane.YAxis.Scale.MajorStep=10;
            myPane.YAxis.Scale.MinorStep=10;
            isStartPoint = false;
        }

        double x = PacketHandler.getMcTime();
        double y = 5;
        double w = PacketHandler.getPacketWidth();
        double h = 5;
        int pColor = PacketHandler.getRowColor();
        BoxObj box; 
        if (pColor == 0)
        {
            box = new BoxObj(x, y, w, h, Color.Black, Color.Tomato);
        }
        else if (pColor == 1)
        {
            box = new BoxObj(x, y, w, h, Color.Black, Color.Beige);
        }
        else if (pColor == 2)
        {
            box = new BoxObj(x, y, w, h, Color.Black, Color.LightSeaGreen);
        }
        else if (pColor == 3)
        {
            box = new BoxObj(x, y, w, h, Color.Black, Color.GreenYellow);
        }
        else
        {
            box = new BoxObj(x, y, w, h, Color.Black, Color.Tomato);
        }

        box.IsVisible = true;
        box.Location.CoordinateFrame = CoordType.AxisXYScale;
        box.ZOrder = ZOrder.A_InFront;
        //zgc.GraphPane.GraphObjList.Add(box);
        myPane.GraphObjList.Add(box);           

        zgc.AxisChange();
        zgc.Invalidate();

    }

任何帮助都会受到高度关注。

感谢。

1 个答案:

答案 0 :(得分:1)

IsClippedToChartRect的{​​{1}}属性设置为true,它将使矩形在Axis矩形内绘制。