ms chart控件使用 语言C#.net,使用MS CHART控件,SQL数据库表htTest(时间,电量,信号)想要实现功能:横坐标时间,纵坐标电量和信号,随时间变化显示电量和信号的曲线.因时间有限没及时找到相关资料,哪位大虾指点下,先谢过咯~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 正好找到很久以前写的:#region 数据获取与图形显示 /// <summary> /// 数据获取与图形显示 /// </summary> private void AnalyseChart() { sql = " select CONVERT(varchar(7), OutDate, 21) as OutDate, "+ " sum(allsum_out-allsum_outback) as AllSUm from V_Out_Gather "+ " where ( CONVERT(varchar(7), OutDate, 21) between '"+dtpDate1.Text+"' and '"+dtpDate2.Text+"') "; sql += " group by CONVERT(varchar(7), OutDate, 21) "; DataTable dt = so.GetDataset(sql).Tables[0] ; cht_Analyse.ColumnCount = (short)dt.Rows.Count ; // cht_Analyse.RowCount = 1 ; //显示图例 cht_Analyse.ShowLegend = true ; for( int i = 0 ;i < dt.Rows.Count ;i ++ ) { cht_Analyse.Column = (short)(i+1) ; cht_Analyse.ColumnLabel = dt.Rows[i][0].ToString() ; } //设置行标名称 cht_Analyse.Row = 1 ; cht_Analyse.RowLabel = "" ; //绑定数据 string a = "0" ; for( int i = 0 ;i < cht_Analyse.ColumnCount ;i ++ ) { for( int j = 0 ;j < cht_Analyse.RowCount ;j++ ) { a = dt.Rows[i][1].ToString() ; cht_Analyse.DataGrid.SetData( (short)(j+1),(short)(i+1),double.Parse(a),0 ) ; } } //设置图标说明显示的位置 this.cht_Analyse.Legend.Location.LocationType = MSChart20Lib.VtChLocationType.VtChLocationTypeTop; //显示坐标值 for( int i = 0 ;i < cht_Analyse.ColumnCount ;i ++ ) { this.cht_Analyse.Plot.SeriesCollection.get__Item((short)(i+1)).DataPoints.get__Item(-1).DataPointLabel.LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeAbovePoint ; } } #endregion ms chart ? 印象中是MS VB3/4的东东.....net 里没这个吧. 偶都用第三方的了.. System.Drawing怎么取曲线任意一横坐标对应的纵坐标,或者我点击鼠标自动标亮横坐标对应曲线上的点的(x,y)? 页面传值在ASP.NET 2.0使用以下四种方式 一个关于timer控件的使用 TimeStamp类型转换为Int64 数据绑定控件问题 请问如何把数据库中数据转成TLV格式的数据? 怎么在C#里调用VBA代码?请写出详细步骤。分不够再加!!! C#高级编程--发表你的意见 高分求.net启动问题 C#如何通过反射调用父类的私有方法 装上了windows 2003 sp1 ,有个很奇怪的问题,bug??? 复合框赋值的问题-急!
#region 数据获取与图形显示
/// <summary>
/// 数据获取与图形显示
/// </summary>
private void AnalyseChart()
{
sql = " select CONVERT(varchar(7), OutDate, 21) as OutDate, "+
" sum(allsum_out-allsum_outback) as AllSUm from V_Out_Gather "+
" where ( CONVERT(varchar(7), OutDate, 21) between '"+dtpDate1.Text+"' and '"+dtpDate2.Text+"') ";
sql += " group by CONVERT(varchar(7), OutDate, 21) ";
DataTable dt = so.GetDataset(sql).Tables[0] ; cht_Analyse.ColumnCount = (short)dt.Rows.Count ; //
cht_Analyse.RowCount = 1 ; //显示图例
cht_Analyse.ShowLegend = true ;
for( int i = 0 ;i < dt.Rows.Count ;i ++ )
{
cht_Analyse.Column = (short)(i+1) ;
cht_Analyse.ColumnLabel = dt.Rows[i][0].ToString() ;
}
//设置行标名称
cht_Analyse.Row = 1 ;
cht_Analyse.RowLabel = "" ;
//绑定数据
string a = "0" ;
for( int i = 0 ;i < cht_Analyse.ColumnCount ;i ++ )
{
for( int j = 0 ;j < cht_Analyse.RowCount ;j++ )
{
a = dt.Rows[i][1].ToString() ;
cht_Analyse.DataGrid.SetData( (short)(j+1),(short)(i+1),double.Parse(a),0 ) ;
}
}
//设置图标说明显示的位置
this.cht_Analyse.Legend.Location.LocationType = MSChart20Lib.VtChLocationType.VtChLocationTypeTop;
//显示坐标值
for( int i = 0 ;i < cht_Analyse.ColumnCount ;i ++ )
{
this.cht_Analyse.Plot.SeriesCollection.get__Item((short)(i+1)).DataPoints.get__Item(-1).DataPointLabel.LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeAbovePoint ;
} }
#endregion