语言C#.net,使用MS CHART控件,SQL数据库表htTest(时间,电量,信号)想要实现功能:横坐标时间,纵坐标电量和信号,随时间变化显示电量和信号的曲线.因时间有限没及时找到相关资料,哪位大虾指点下,先谢过咯~~

解决方案 »

  1.   

    正好找到很久以前写的:
    #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
      

  2.   

    ms chart ? 印象中是MS VB3/4的东东.....net 里没这个吧. 偶都用第三方的了..