OleDbConnection ocon = new OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings[0].ToString());//("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://pic.MDB;");
/* SqlConnection scon = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://pic.MDB;");//(System.Configuration.ConfigurationSettings.AppSettings[0]);
SqlCommand scmd = new SqlCommand("select * from DataTab",scon);
SqlDataAdapter da = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
da.Fill(ds);
*/
OleDbCommand ocmd = new OleDbCommand("select * from DataTab",ocon);
OleDbDataAdapter da = new OleDbDataAdapter(ocmd);
DataSet ds = new DataSet();
da.Fill(ds);
WebChart1.Series.Add(new ComponentArt.Charting.Series("系列4"));
Response.Write(ds.Tables[0].Columns[0].Caption.ToString());
//定义x,y轴
double[] y = new double[] { 50, 60, 70, 80, 90, 100 };
string[] x = new string[] { "50", "100", "150", "200", "", "" };
WebChart1.DefineValue("x", x);
WebChart1.DefineValue("y", y);
WebChart1.DataBind();
//设置折线点的数据
int n = ds.Tables[0].Columns.Count;
int p = ds.Tables[0].Rows.Count;
int[] sales = new int[n];
for (int index1 = 1; index1 < n;index1++ )
{
sales[index1] = int.Parse(ds.Tables[0].Rows[0][index1].ToString());
}
Color[] colour = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":y", sales);
WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":color", colour);
int[] sales1 = new int[n];
for (int index2 = 1; index2 < n; index2++)
{
sales1[index2] = int.Parse(ds.Tables[0].Rows[2][index2].ToString());
}
Color[] colour1 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":y", sales1);
WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":color", colour1);
int[] sales2 = new int[n];
for (int index2 = 1; index2 < n; index2++)
{
sales2[index2] = int.Parse(ds.Tables[0].Rows[1][index2].ToString());
}
Color[] colour2 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":y", sales2);
WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":color", colour2);
double[] sales3 = new double[8] { 68.35, 70.84, 67.79, 56.36, 56.88, 81.87, 88.2, 108 };
Color[] colour3 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue("系列4:y", sales3);
WebChart1.DefineValue("系列4:color", colour3);
/* SqlConnection scon = new SqlConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D://pic.MDB;");//(System.Configuration.ConfigurationSettings.AppSettings[0]);
SqlCommand scmd = new SqlCommand("select * from DataTab",scon);
SqlDataAdapter da = new SqlDataAdapter(scmd);
DataSet ds = new DataSet();
da.Fill(ds);
*/
OleDbCommand ocmd = new OleDbCommand("select * from DataTab",ocon);
OleDbDataAdapter da = new OleDbDataAdapter(ocmd);
DataSet ds = new DataSet();
da.Fill(ds);
WebChart1.Series.Add(new ComponentArt.Charting.Series("系列4"));
Response.Write(ds.Tables[0].Columns[0].Caption.ToString());
//定义x,y轴
double[] y = new double[] { 50, 60, 70, 80, 90, 100 };
string[] x = new string[] { "50", "100", "150", "200", "", "" };
WebChart1.DefineValue("x", x);
WebChart1.DefineValue("y", y);
WebChart1.DataBind();
//设置折线点的数据
int n = ds.Tables[0].Columns.Count;
int p = ds.Tables[0].Rows.Count;
int[] sales = new int[n];
for (int index1 = 1; index1 < n;index1++ )
{
sales[index1] = int.Parse(ds.Tables[0].Rows[0][index1].ToString());
}
Color[] colour = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":y", sales);
WebChart1.DefineValue(ds.Tables[0].Rows[0][0].ToString() + ":color", colour);
int[] sales1 = new int[n];
for (int index2 = 1; index2 < n; index2++)
{
sales1[index2] = int.Parse(ds.Tables[0].Rows[2][index2].ToString());
}
Color[] colour1 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":y", sales1);
WebChart1.DefineValue(ds.Tables[0].Rows[2][0].ToString() + ":color", colour1);
int[] sales2 = new int[n];
for (int index2 = 1; index2 < n; index2++)
{
sales2[index2] = int.Parse(ds.Tables[0].Rows[1][index2].ToString());
}
Color[] colour2 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":y", sales2);
WebChart1.DefineValue(ds.Tables[0].Rows[1][0].ToString() + ":color", colour2);
double[] sales3 = new double[8] { 68.35, 70.84, 67.79, 56.36, 56.88, 81.87, 88.2, 108 };
Color[] colour3 = new Color[8] { Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White, Color.Red, Color.White };
WebChart1.DefineValue("系列4:y", sales3);
WebChart1.DefineValue("系列4:color", colour3);