Home > Net >  The X axis display database time chart chart
The X axis display database time chart chart

Time:11-19



Button click, a list of values from SQL read a list of time, time column is bound to the X axis, numerical bound to Y, X the most the right side of the scale and the label can't display, could you tell me what's the solution? The code is as follows:

String searchString=the string. Format (" select [time], [1] # space temperature from the Data where [time] between '{0}' and '{1}' order by ASC [time] ", dtPickerStart. Value, dtPickerEnd. Value);
SqlDataAdapter dap=new SqlDataAdapter (searchString, conn);
The DataSet ds=new DataSet ();
Dap. The Fill (ds);
If (ds) Tables [0]!=null)
{

//chart1. The DataSource=ds. Tables [0].
//chart1. Series [0]. XValueMember="time";
//chart1. Series [0]. YValueMembers="1 # space temperature";
//chart1. DataBind ();
//chart1 ChartAreas [0]. AxisX. Minimum=(((DateTime) ds. Tables [0]. Rows [0] [0])). ToOADate ();
//chart1 ChartAreas [0]. AxisX. Maximum=((DateTime) (ds) Tables [0]. Rows [ds. The Tables [0]. Rows. The Count - 1] [0])). ToOADate ();
Chart1. Series [0]. XValueType=ChartValueType. DateTime;
Chart1. ChartAreas [0]. AxisX. Interval=1;//set the X axis coordinate interval is 1
Chart1. ChartAreas [0]. AxisX. LabelStyle. IsStaggered=true;//Settings are interlaced display, such as data much time into two rows to display

List ListX=new List (a);
List ListY=new List (a);
ListX. The Clear ();
ListY. The Clear ();
for (int i=0; i {
ListX. Add (Convert. ToDateTime (ds) Tables [0]. Rows [I] [0]));
ListY. Add (Convert. ToDouble (ds) Tables [0]. Rows [I] [1]));
}
Chart1. Series [0]. Points. DataBindXY (listX, listY);
Chart1. ChartAreas [0]. AxisX. Minimum=listX [0]. ToOADate ();
Chart1. ChartAreas [0]. AxisX. Maximum=listX [ds. The Tables [0]. Rows. The Count - 1]. ToOADate ();

}
Is there a way to solve the most scale and label can't display on the right side of the figure?
Above is online reference code, does excuse me besides above the standard optimal SQL read two column (a column, a column number) method on how to display the chart?
  • Related