关于zedGraph动态显示的问题 使用zedGraph进行实时动态显示,并标注数值,请问有什么办法能然数值不超过统计表啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 图片挂了,http://hi.baidu.com/pengyu25051/album/item/5a4f211d95cad1c885e5e3b27f3e6709c83d51cf.html# 是啊,数值都是左移过来的,可以它超过了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(); [求助]如何把checkbox作为combobox的items进行添加? 求效果:弹出一个对话框,父页面便会色,同时不可操作。 如何选择panel的上下关系 MDI的两个子窗体切换问题 C# 对big5 的quoted-printable編碼的郵件解码? 状态栏显示系统时间? 番茄花园主题与进度条视觉样式不兼容问题 调用API问题,如何对应相应的数据类型? 有关线程的问题! 请问TCP方式用哪种方法传送文件比较方便? 【WPF】-RadioButton-数据绑定!!! 一个小程序员关于Silverlight 和 WPF的困惑100分
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();