Http://msdn.microsoft.com/zh-cn/dd488514
DataBindCrossTable (IEnumerable, String)
. NET Framework class library
Chart...:. DataBindCrossTable method (IEnumerable, String)
Bind the chart data to the table and create a sequence for each unique value in the given column.
Namespace: System. Web. UI. DataVisualization. Charting
Assembly: System. Web. DataVisualization (in System. Web. DataVisualization. dll)
Syntax
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
Parameters
DataSource
Type: System. Collections...:. IEnumerable
Data source.
SeriesGroupByField
Type: System...:. String
The name of the field used to divide the data into sequences.
XField
Type: System...:. String
The name of the field used for the X value.
YFields
Type: System...:. String
A comma-separated list lists the names of fields with Y values.
OtherFields
Type: System...:. String
Other data point attributes that can be bound.
Remarks
The series will be automatically added to the chart, depending on the number of unique values in the seriesGroupByField column given by the data source. In other words, the creation of the series depends on the column group.
The data source can be OleDbDataReader, SqlDataReader, or DataView objects. Note that all sets that implement the IEnumerable interface are available.
In addition to the X and Y values, you can bind other data point attributes. The format is PointProperty = field [{format}] [, PointProperty = field [{format}]. For example, "Tooltip = Price {C1}, Href = WebSiteName ".
These data point attributes are listed as follows: AxisLabel () ToolTip (), Url (), PostBackValue ()()(), Label (), LegendText (), LegendToolTip () and CustomProperties ()()(), they are all the names of custom properties.
--------------------------------------------------
{
// StrSql = "select hour, count (*) as lNum from (select str (DATEPART (hh, jgsj )) + 'hour AS hour from epdb where "+ strWhere +") A group by hour ";
StrSql = "select hour, count (*) as lNum from (select str (DATEPART (hh, jgsj )) + 'hour AS hour from epdb a "+ leftJoin +" where "+ strWhere +") A group by hour ";
// Clq test
StrSql = "select hour, lane number, count (*) as lNum from (select str (DATEPART (hh, jgsj) + 'hour 'as hour, str (CLBH) + 'driveway 'as Lane NO. from epdb a "+ leftJoin +" where "+ strWhere +") A group by hour, Lane NO ";
DataSet ds = WLCDB. MsSQL. DoAnySQLExecuteDataSet (strSql );
DataView dv = new DataView (ds. Tables [0]);
// Chart1.Series ["login"]. Points. DataBindXY (dv, "Hour", dv, "lNum ");
//--------------------------------------------------
// Chart1.DataBindTable (dv, "Hour ");
Chart1.DataBindCrossTable (dv, "driveway", "Hour", "lNum ","");
// Chart1.Series. Add ("t ");
// Chart1.Series ["t"]. ChartType = System. Web. UI. DataVisualization. Charting. SeriesChartType. Line;
// Chart1.Series ["t"]. Points. DataBindXY (dv, "Hour", dv, "lNum ");
// Chart1.Series. Add ("t2 ");
// Chart1.Series ["t2"]. ChartType = System. Web. UI. DataVisualization. Charting. SeriesChartType. Spline;
// Chart1.Series ["t2"]. Points. DataBindXY (dv, "Hour", dv, "lNum ");
Chart1.Visible = true;
Image1.Visible = false;
}