C#用chart控件做图表不显示。请指教,急
voidFillPieChart(){stringConnectionWords="Provider=Microsoft.Jet.OLEDB.4.0;DataSource...
void FillPieChart()
{
string ConnectionWords = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=chanyechaxun.mdb;";
OleDbConnection con = new OleDbConnection(ConnectionWords);
con.Open();
OleDbCommand da = new OleDbCommand("select number from Sheet1 ", con);
//DataSet ds = new DataSet();
//da.Fill(ds, "starea");
OleDbDataReader ggg = da.ExecuteReader();
ggg.Read();
double[] y = new double[100];
///string[] x = new string[] { "甲", "乙", "丙", "丁" };
//int[] y = new int[] { 123, 273, 92, 244
int i = 0;
while (ggg.Read())
{
//x[i] = sss[i].ToString();
y[i] = Convert.ToDouble(ggg[0].ToString());
i = i + 1;
}
OleDbCommand ds = new OleDbCommand("select classification from Sheet1 ", con);
OleDbDataReader sss = ds.ExecuteReader();
sss.Read();
string[] x = new string[100];
int j = 0;
while (sss.Read())
{
x[j] = sss[0].ToString();
j = j + 1;
}
this.chart1.Legends[0].Alignment = StringAlignment.Center;
this.chart1.Legends[0].Docking = Docking.Bottom;
this.chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
this.chart1.Series[0].ChartType = SeriesChartType.Column;
this.chart1.Series[0]["ColumnLabelStyle"] = "Outside";
this.chart1.Series[0].Points.DataBindXY(x, y);
}
它一直说我字符串格式不对,可我access里面用的都是数字和文本,而且数字没有小数等问题 展开
{
string ConnectionWords = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=chanyechaxun.mdb;";
OleDbConnection con = new OleDbConnection(ConnectionWords);
con.Open();
OleDbCommand da = new OleDbCommand("select number from Sheet1 ", con);
//DataSet ds = new DataSet();
//da.Fill(ds, "starea");
OleDbDataReader ggg = da.ExecuteReader();
ggg.Read();
double[] y = new double[100];
///string[] x = new string[] { "甲", "乙", "丙", "丁" };
//int[] y = new int[] { 123, 273, 92, 244
int i = 0;
while (ggg.Read())
{
//x[i] = sss[i].ToString();
y[i] = Convert.ToDouble(ggg[0].ToString());
i = i + 1;
}
OleDbCommand ds = new OleDbCommand("select classification from Sheet1 ", con);
OleDbDataReader sss = ds.ExecuteReader();
sss.Read();
string[] x = new string[100];
int j = 0;
while (sss.Read())
{
x[j] = sss[0].ToString();
j = j + 1;
}
this.chart1.Legends[0].Alignment = StringAlignment.Center;
this.chart1.Legends[0].Docking = Docking.Bottom;
this.chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
this.chart1.Series[0].ChartType = SeriesChartType.Column;
this.chart1.Series[0]["ColumnLabelStyle"] = "Outside";
this.chart1.Series[0].Points.DataBindXY(x, y);
}
它一直说我字符串格式不对,可我access里面用的都是数字和文本,而且数字没有小数等问题 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询