使用zedGraph进行实时动态显示,并标注数值,请问有什么办法能然数值不超过统计表啊?

解决方案 »

  1.   

    图片挂了,http://hi.baidu.com/pengyu25051/album/item/5a4f211d95cad1c885e5e3b27f3e6709c83d51cf.html#
      

  2.   

    是啊,数值都是左移过来的,可以它超过了Y轴,到控件的边缘才消失,求解啊
    void dispatcherTimer_TickSpeed(object sender, EventArgs e)
            {
                //确保CurveList不为空
                if (zedSpeedControl.GraphPane.CurveList.Count <= 0)
                {
                    return;
                }
                //取Graph第一个曲线,也就是第一步:在GraphPane.CurveList集合中查找CurveItem
                LineItem curve = zedSpeedControl.GraphPane.CurveList[0] as LineItem;
                if (curve == null)
                {
                    return;
                }
                // Get the PointPairList
                //第二步:在CurveItem中访问PointPairList(或者其它的IPointList),根据自己的需要增加新数据或修改已存在的数据
                IPointListEdit list = curve.Points as IPointListEdit;   // If this is null, it means the reference at curve.Points does not
                // support IPointListEdit, so we won't be able to modify it
                if (list == null)
                {
                    return;
                }
                double x = (double)new XDate(DateTime.Now);//设置X轴格式
                double y = ran.Next(0, 160);
                list.Add(x, y);
                //第三步:调用ZedGraphControl.AxisChange()方法更新X和Y轴的范围            //////////////////动态标注///////////////////////////
                ZedGraph.GraphPane myPane = zedSpeedControl.GraphPane;//获取引用              LineItem myCurve = new LineItem("平均速度", list, Color.Red
                                                    , SymbolType.None);
                const double offset = 5;
                int Count = 30;
                // 为每个点加标注
                for (int i = 0; i < Count; i++)
                {
                    PointPair pt = myCurve.Points[i];
                    // TextObj text = new TextObj(pt.Y.ToString("0"), pt.X, pt.Y + offset, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                    TextObj text = new TextObj(pt.Y.ToString("0"), pt.X, pt.Y + offset, CoordType.AxisXYScale, AlignH.Left, AlignV.Top);
                    text.ZOrder = ZOrder.A_InFront;
                    // 隐藏标注的边框和填充
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.IsVisible = false;
                    // 选择标注字体0°
                    text.FontSpec.Angle = 0;
                    text.FontSpec.FontColor = Color.Red;
                    int num = Convert.ToInt32(text.Text);
                    //if (num < 40)
                    //{
                    //    if (num > 0)
                    //    {
                            myPane.GraphObjList.Add(text);
                        //}
                    //}            }
                          /////////////////////////动态标注结束/////////////////////////            zedSpeedControl.AxisChange();
                //第四步:调用Form.Invalidate()方法更新图表
                zedSpeedControl.Invalidate();