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;
}