string dbPath = @"D:\历年高考分数.db";
string sq = @"Data Source=" + dbPath;
m = new SQLiteConnection(sq);
m.Open();
SQLiteDataAdapter mAdapter = new SQLiteDataAdapter("select Volume1,Volume2 from 饼形图2", m);
DataSet ds = new DataSet();
mAdapter.Fill(ds);
DataTable dt = ds.Tables[0];
//设置图表的数据
chart3.DataSource = dt;
//chart3.Series.Clear();
chart3.Series[0].ChartType = SeriesChartType.Pie;//设置形状
chart3.Series[0].XValueMember = "Volume1";//图例数据成员列
chart3.Series[0].YValueMembers = "Volume2";//饼形图上数据成员列
chart3.Series[0].IsValueShownAsLabel = true;//显示标签
chart3.DataBind();
chart3.Width = 260;
chart3.Height = 260;
m.Close();
下面的几种尝试都不对
一:chart1.ChartAreas[0].AxisX.LabelStyle.Format = "#LEGENDTEXT";//显示当前图例的标签文本
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#VAL%";//显示当前图例的所占的百分比
二:chart1.Series[0].Label = "#VALY%";
三:chart1.ChartAreas[0].AxisX.LabelStyle.Format = "#VALX";
chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#VALY%";