clq

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

http://msdn.microsoft.com/zh-cn/dd488514

DataBindCrossTable 方法 (IEnumerable, String, String, String, String)
.NET Framework 类库
Chart..::.DataBindCrossTable 方法 (IEnumerable, String, String, String, String)

将图表的数据绑定到表,并为给定列中的每个唯一值创建一个序列。

命名空间: System.Web.UI.DataVisualization.Charting
程序集: System.Web.DataVisualization(在 System.Web.DataVisualization.dll 中)
语法

Public Sub DataBindCrossTable ( _
    dataSource As IEnumerable, _
    seriesGroupByField As String, _
    xField As String, _
    yFields As String, _
    otherFields As String _
)

    public void DataBindCrossTable(
        IEnumerable dataSource,
        string seriesGroupByField,
        string xField,
        string yFields,
        string otherFields
    )

public:
void DataBindCrossTable(
    IEnumerable^ dataSource,
    String^ seriesGroupByField,
    String^ xField,
    String^ yFields,
    String^ otherFields
)

member DataBindCrossTable :
        dataSource:IEnumerable *
        seriesGroupByField:string *
        xField:string *
        yFields:string *
        otherFields:string -> unit

参数

dataSource
    类型:System.Collections..::.IEnumerable
    数据源。

seriesGroupByField
    类型:System..::.String
    用于将数据分组成序列的字段的名称。

xField
    类型:System..::.String
    用于 X 值的字段的名称。

yFields
    类型:System..::.String
    一个逗号分隔列表,其中列出了 Y 值的字段的名称。

otherFields
    类型:System..::.String
    可以绑定的其他数据点属性。

备注

系列将被自动添加到图表中,这取决于数据源给定的 seriesGroupByField 列中唯一值的个数,换言之,系列的创建取决于列的分组。

数据源可以是 OleDbDataReader、SqlDataReader 或 DataView 对象。 请注意,所有实现 IEnumerable 接口的集合都可供使用。

除 X 和 Y 值以外,还可以绑定其他数据点属性。 格式是:PointProperty = 字段[{格式}] [,PointProperty = 字段[{格式}]]。 例如:“Tooltip=Price{C1},Href=WebSiteName”。

这些数据点属性的列表如下所示:AxisLabel()()()ToolTip()()()、Url()()()、PostBackValue()()()、Label()()()、LegendText()()()、LegendToolTip()()() 和 CustomProperties()()(),它们都是自定义属性的名称。
--------------------------------------------------

        {
            //strSql = "select 小时, count(*) as lNum from (select str(DATEPART(hh,jgsj)) + '时' AS 小时  from epdb  where  " + strWhere + ") A group by 小时";
            strSql = "select 小时, count(*) as lNum from (select str(DATEPART(hh,jgsj)) + '时' AS 小时  from epdb a " + leftJoin + " where  " + strWhere + ") A group by 小时";

            //clq test
            strSql = "select 小时, 车道号, count(*) as lNum from (select str(DATEPART(hh,jgsj)) + '时' AS 小时, str(CLBH) + '车道' as 车道号  from epdb a " + leftJoin + " where  " + strWhere + ") A group by 小时,车道号";
            
            DataSet ds = WLCDB.MsSQL.DoAnySQLExecuteDataSet(strSql);
            DataView dv = new DataView(ds.Tables[0]);
            //Chart1.Series["login"].Points.DataBindXY(dv, "小时", dv, "lNum");

            //--------------------------------------------------
            //Chart1.DataBindTable(dv, "小时");
            Chart1.DataBindCrossTable(dv, "车道号", "小时", "lNum", "");
            
            //Chart1.Series.Add("t");
            //Chart1.Series["t"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Line;
            //Chart1.Series["t"].Points.DataBindXY(dv, "小时", dv, "lNum");

            //Chart1.Series.Add("t2");
            //Chart1.Series["t2"].ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Spline;
            //Chart1.Series["t2"].Points.DataBindXY(dv, "小时", dv, "lNum");

            Chart1.Visible = true;
            Image1.Visible = false;
        }

posted on 2012-02-09 16:31  clq  阅读(1176)  评论(1编辑  收藏  举报