用ZedGraph控件作图圆
转自原文 用ZedGraph控件作图圆
用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;
zedGraphControl1.GraphPane.XAxis.Scale.Min = 0;
zedGraphControl1.AxisChange();
zedGraphControl1.Invalidate();
zedGraphControl1.Refresh();
2. 这个需要从GraphObj派生,覆盖Draw方法自己画,比如:
public class MyEllipseObj : EllipseObj
{
public MyEllipseObj(){}
public MyEllipseObj(double x, double y, double width, double height) : base(x, y, width, height){}
public MyEllipseObj(double x, double y, double width, double height, Color borderColor, Color fillColor)
: base(x, y, width, height, borderColor, fillColor) {} public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
{
if (pane is GraphPane && ((GraphPane)pane).Chart != null)
{
var oldClip = g.Clip.Clone();
g.SetClip((pane as GraphPane).Chart.Rect);
base.Draw(g, pane, scaleFactor);
g.Clip = oldClip;
}
else
base.Draw(g, pane, scaleFactor);
}
}
然后用刀EllipseObj的地方改成MyEllipseObj
3. 同样还是调整坐标轴的设置:
zedGraphControl1.GraphPane.YAxis.Scale.MajorStep = 0.2; // 调整刻度间距
zedGraphControl1.GraphPane.YAxis.Scale.Max = 2; // 调整坐标轴最大值
4. 用饼图可以实现:
http://zedgraph.dariowiz.com/indexe246.html?title=Pie_Chart_Demo
5. 可以。基本上所有图形对象都可以派生重写Draw绘图方法,比如:
public class MyGraphPane : GraphPane
{
public override void Draw(Graphics g)
{
base.Draw(g); // 调用基类画图方法画出原来的图形
// 添加你自己的画图放啊
}
}
然后用的时候把GraphPane替换成派生的MyGraphPane
var myPane = new MyGraphPen();
zedGraphControl1.GraphPane = myPane;
===============
很多问题网上都有现成的解答,多看看帮助和论坛讨论
http://zedgraph.dariowiz.com/
用ZedGraph控件作图圆的更多相关文章
- zedgraph控件的一些比较有用的属性 转
(1)zedgraph控件属性具体解释: AxisChange()() ->> This performs an axis change command on the graphPane. ...
- ZedGraph控件的使用
http://blog.chinaunix.net/uid-20776117-id-1847015.html 在我们编写程序的时候,有时候是要做一些统计的,为了达到一目了然的效果,饼状图,曲线图,柱状 ...
- ZedGraph控件的使用 --归类(转帖)
在我们编写程序的时候,有时候是要做一些统计的,为了达到一目了然的效果,饼状图,曲线图,柱状图都是很好的表现统计的直观形式.这个时候,ZedGraph控件给我们带来了极大的方便. 1.下载ZedGrap ...
- zedgraph控件怎么取得鼠标位置的坐标值(转帖)
我想取得zedgraph控件上任意鼠标位置的坐标值,IsShowCursorValues可以显示鼠标位置的值但是不能提取赋值给其他的变量.用PointValueEvent这个事件又只能得到已经画出的点 ...
- zedgraph控件的一些比较有用的属性
(1)zedgraph控件属性具体解释: AxisChange()() ->> This performs an axis change command on the graphPane. ...
- ZedGraph控件生成饼图、拆线图和柱状图例程
这几天做了个自己觉得还蛮NB的功能,在GRID中选中一块数据,然后右键菜单即可生成三种图形,还可以互相切换,对了,饼图还添加了鼠标点击分离的处理,大致如图: 用的控件就是ZedGraph,我把它继承封 ...
- C#上位机中ZedGraph控件的使用
上位机程序控制PLC模拟量通道输出周期性正弦波信号,并采集所造成改变的模拟量输入信号,并绘制数据变化曲线. 界面如图: 最后测试效果如图: 代码: using System; using System ...
- C# ZedGraph 控件各属性以及示例
ZedGraph属性\方法介绍 Copy(Boolean) ->> 将图像复制到剪贴板.DoPageSetup()() ->> 打开打印设置对话框. DoPrint()() - ...
- 【实验室笔记】zedgraph控件属性总结
//图表的X轴刻度线是否显示 this.zedGraphControl1.GraphPane.XAxis.MajorGrid.IsVisible = true; //图表的X轴刻度线的颜色 this. ...
随机推荐
- Git详解之四 服务器上的Git
以下内容转载自:http://www.open-open.com/lib/view/open1328069988843.html 服务器上的 Git 到目前为止,你应该已经学会了使用 Git 来完成日 ...
- BZOJ4668 冷战 【LCT】
Description 1946 年 3 月 5 日,英国前首相温斯顿·丘吉尔在美国富尔顿发表"铁幕演说",正式拉开了冷战序幕. 美国和苏联同为世界上的"超级大国&quo ...
- pat甲级 1152 Google Recruitment (20 分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the p ...
- C++ sort 函数用法
MSDN中的定义: template<class RanIt>void sort(RanIt first, RanIt last); //--> 1)template<clas ...
- oracle-分区(笔记)
partition by 用于指定分区方式 range 表示分区的方式是范围划分 partition pn 用于指定分区的名字 values less than 指定分区的上界(上限) ------- ...
- 《DSP using MATLAB》示例Example7.5
代码: h = [-4, 1, -1, -2, 5, 6, 6, 5, -2, -1, 1, -4]; M = length(h); n = 0:M-1; [Hr, w, b, L] = Hr_Typ ...
- 《selenium2 python 自动化测试实战》(3)——操作测试对象
上一节我们说了如何定位元素,定位到元素以后就涉及到对元素的操作了,webdriver中常用的操作元素的方法有: clear ——用于清除输入框的默认内容 send_keys ——用于在一个输入框里 ...
- scrapy爬取验证码登录网页
scrapy 验证码登录程序, https://accounts.douban.com/login # -*- coding: utf-8 -*- import scrapy import urlli ...
- c++调用fortran程序中遇到的问题
一.C++动态调用Fortran DLL (1)创建FORTRAN DLL工程,生成forsubs.dll文件供调用. ! forsubs.f90 ! ! FUNCTIONS/SUBROUTINES ...
- 【最全 干货 实例】 缓存手册(Memcached、redis、RabbitMQ)
http://www.cnblogs.com/suoning/p/5807247.html 本章内容: Memcached 简介.安装.使用 Python 操作 Memcached 天生支持集群 re ...