我正在使用 C# 语言处理 Asp.Net 图表。我为用户提供选项,让他从数据库中选择字段并形成图表,还可以选择用名称保存这些设置,并在用户想要查看他的保存设置时创建一个智能列表他只是单击并形成图形。但是当用户单击他的保存设置图形的名称时,格式不正确并且也没有正确显示轴,我的代码如下:
protected void btnShowSmartList_Click(object sender, EventArgs e)
{
string _SmartList ;
ds = GetDataSet("SELECT [Sql_Query] FROM [DWH_SmartList] WHERE sys_SmartList_No=" + ddSmartQueryList.SelectedValue) ;
_SmartList = Convert.ToString(ds.Tables[0].Rows[0]["Sql_Query"]);
ds.Tables[0].Dispose();
ds = new DataSet();
ds = GetDataSet(_SmartList);
Chart1.DataSource = ds;
Chart1.Legends.Add("Inspection_Date").Title = "Inspection_Date";
Chart1.ChartAreas["ChartArea1"].AxisX.Title = Dd_List.SelectedValue;
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisX.MajorTickMark.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorTickMark.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisX.MinorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisX.MinorTickMark.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MinorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MinorTickMark.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.Title = Dd_ListY.SelectedValue;
Chart1.Series["Series1"].XValueMember = Dd_List.SelectedValue;
Chart1.Series["Series1"].YValueMembers = Dd_ListY.SelectedValue;
Chart1.Series["Series1"].LegendText = Dd_ListY.SelectedValue;
this.GridFormatting();
Chart1.DataBind();
//Chart1.BackColor = System.Drawing.Color.White;
// this.Chart1.ChartAreas["ChartArea1"].AxisY.IsStartedFromZero = false;
GridView1.SelectedIndex = 0;
GridView1.DataSource = ds;
GridView1.DataBind();
}
网格工作得很好,但图表不行