ZedGraph图表控件 X轴显示时间 C#
2013-08-23 15:08
761 查看
private void CreateGraph(ZedGraphControl
zgc)
{
//zgc.Controls.Clear();
GraphPane myPane = zgc.GraphPane;
//添加新的控件前先将面板上已经存在的控件清除。
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();
// Set the titles and axis labels
myPane.Title.Text = "指数趋势";
myPane.XAxis.Title.Text = "序号";
myPane.YAxis.Title.Text = "指数";
DateTime dt;
String[] szx = new String[dataGridView3.RowCount];//X轴的日期数组
Double[] szy = new Double[dataGridView3.RowCount];//Y轴的数据数组
for (int i = 0; i < dataGridView3.RowCount;
i++)
{
//list.Add(i, Convert.ToDouble(dataGridView3[2,
i].Value.ToString()));
dt = (DateTime)dataGridView3[3,i].Value;
szx[i] = dt.ToString("MM-dd hh:mm:ss");//按照02-29 18:00:00显示
szy[i] = Convert.ToDouble(dataGridView3[2,
i].Value.ToString());
}
myPane.XAxis.Type = AxisType.Text;
// Generate a blue curve with circle symbols, and "My Curve 2" in
the legend
//添加X轴、Y轴的数据到面板上,但是由于AddCurve方法没有匹配的参数,所以第二个X轴想显示
//时间数据时,要先设置为null,然后在下面单独添加。
LineItem myCurve = myPane.AddCurve("指数", null, szy, Color.Blue,
SymbolType.Circle);
myPane.XAxis.Scale.TextLabels = szx;//添加日期到X轴
// Fill the area under the curve with a white-red gradient at 45
degrees
myCurve.Line.Fill = new Fill(Color.White, Color.White, 45F);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Fill the axis background with a color gradient
myPane.Chart.Fill = new Fill(Color.White,
Color.LightGoldenrodYellow, 45F);
// Fill the pane background with a color gradient
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255),
45F);
// Calculate the Axis Scale Ranges
zgc.AxisChange();
zgc.Refresh();
}
zgc)
{
//zgc.Controls.Clear();
GraphPane myPane = zgc.GraphPane;
//添加新的控件前先将面板上已经存在的控件清除。
myPane.CurveList.Clear();
myPane.GraphObjList.Clear();
// Set the titles and axis labels
myPane.Title.Text = "指数趋势";
myPane.XAxis.Title.Text = "序号";
myPane.YAxis.Title.Text = "指数";
DateTime dt;
String[] szx = new String[dataGridView3.RowCount];//X轴的日期数组
Double[] szy = new Double[dataGridView3.RowCount];//Y轴的数据数组
for (int i = 0; i < dataGridView3.RowCount;
i++)
{
//list.Add(i, Convert.ToDouble(dataGridView3[2,
i].Value.ToString()));
dt = (DateTime)dataGridView3[3,i].Value;
szx[i] = dt.ToString("MM-dd hh:mm:ss");//按照02-29 18:00:00显示
szy[i] = Convert.ToDouble(dataGridView3[2,
i].Value.ToString());
}
myPane.XAxis.Type = AxisType.Text;
// Generate a blue curve with circle symbols, and "My Curve 2" in
the legend
//添加X轴、Y轴的数据到面板上,但是由于AddCurve方法没有匹配的参数,所以第二个X轴想显示
//时间数据时,要先设置为null,然后在下面单独添加。
LineItem myCurve = myPane.AddCurve("指数", null, szy, Color.Blue,
SymbolType.Circle);
myPane.XAxis.Scale.TextLabels = szx;//添加日期到X轴
// Fill the area under the curve with a white-red gradient at 45
degrees
myCurve.Line.Fill = new Fill(Color.White, Color.White, 45F);
// Make the symbols opaque by filling them with white
myCurve.Symbol.Fill = new Fill(Color.White);
// Fill the axis background with a color gradient
myPane.Chart.Fill = new Fill(Color.White,
Color.LightGoldenrodYellow, 45F);
// Fill the pane background with a color gradient
myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255),
45F);
// Calculate the Axis Scale Ranges
zgc.AxisChange();
zgc.Refresh();
}
相关文章推荐
- 一个比较好用的轻量级时间选择控件 &nbsp; ----- &nbsp; JQUERY特效模板
- C# Menu 导航菜单控件Apple Safari & Google Chrome浏览器上显示无效问题
- Excel 利用日期控件输入时间
- C#在一个控件上显示电脑当前的时间
- C#中,当鼠标移动到控件上,动态显示提示内容 -> 用代码操作ToolTip
- C#winform界面中如何显示当前时间,是用lable控件实现
- C# WINFORM 某些控件实现联想输入…
- C#新线程中操作主线程的控件 ,解…
- C#&nbsp;限制TextBox控件中只能输入数字
- JAVA 框架显示系统时间
- Demo:Repeater 控件显示Message
- android控件TextView之&nbsp;分段显示不…
- C# treeview 控件动态绑定数据
- ZedGraph:一个同时支持WinForm和WebForm的开源图表控件(基于LGPL协议,.NET 2.0 C#源代码)
- java 显示当前的时间
- C#&nbsp;测试代码段性能耗时
- C#.NET常见问题(FAQ)-如何使用2D绘图控件ZedGraph绘制坐标轴和坐标曲线
- c# 一个简单的加密解密算法
- asp 中时间控件选择的值提交后不显示
- C#&nbsp;判断批处理是否完成&nbsp;方法