用ZedGraph控件绘制圆
各位:
我想利用第三方控ZedGraph在WinForm窗体中绘制图形如,圆,填充圆,只是简单的圆图形,但一直没有找到相应的方法,网上的资料都是些绘制图表,拆线,圆饼类。对我有些不太适用。
现求教各位。谢谢。主要是看重此软件的缩放功能,实时性比较好,因为我是做工业UI的。
Add an EllipseItem to the graph, then add the following code to your ReSize event for the form:
// Fix the ellipseItem to a perfect circle by using a fixed height, but a variable
// width
EllipseItem ellipse = zedGraphControl1.GraphPane.GraphItemList[0] as EllipseItem;
if ( ellipse != null )
{
GraphPane myPane = zedGraphControl1.GraphPane;
float dx = (float) ( myPane.XAxis.Max - myPane.XAxis.Min );
float dy = (float) ( myPane.YAxis.Max - myPane.YAxis.Min );
float xPix = myPane.AxisRect.Width * ellipse.Location.Width / dx;
float yPix = myPane.AxisRect.Height * ellipse.Location.Height / dy;
ellipse.Location.Width *= yPix / xPix;
// alternatively, use this to vary the height but fix the width
// (comment out the width line above)
//ellipse.Location.Height *= xPix / yPix;
}
This will give you a true circle, with a fixed height and a variable width as you resize the graph to any size.
John
以上是在一英文网站上找到一点点相关资料,试了一下,不行,主要是“EllipseItem ”类型没有,不知本人水平有限还是怎么的,没弄出现。
------解决方案--------------------就只画圆的话,用得着第三方控件吗?
------解决方案--------------------这里有人写不错还有三角函数例子
------解决方案--------------------1. 设置坐标范围都为正数就可以了,设置后不要忘记刷新:
zedGraphControl1.GraphPane.YAxis.Scale.Min = 0;