C# 如何在ASP.NET中用C突出显示样条曲线图中的最高和最低日期值
我正在为我的组织准备一张图表。我想用不同的颜色突出显示ASP中样条曲线图系列值中最高870和最低600的学生姓名/分数。使用C 表数据:C# 如何在ASP.NET中用C突出显示样条曲线图中的最高和最低日期值,c#,asp.net,C#,Asp.net,我正在为我的组织准备一张图表。我想用不同的颜色突出显示ASP中样条曲线图系列值中最高870和最低600的学生姓名/分数。使用C 表数据: David 700 John 870 Neil 810 Robert 720 Andrew 600 代码隐藏: protected void Page_Load(object sender, EventArgs e) { DataBindingToChart(); } public void DataBindingToChart() {
David 700
John 870
Neil 810
Robert 720
Andrew 600
代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
DataBindingToChart();
}
public void DataBindingToChart()
{
string Query = "select * from Student;";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_Connection"].ConnectionString);
con.Open();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(Query, con);
adp.Fill(ds);
dt = ds.Tables[0];
string[] x = new string[dt.Rows.Count];
int[] y = new int[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
x[i] = dt.Rows[i][0].ToString();
y[i] = Convert.ToInt32(dt.Rows[i][1]);
}
Chart1.Series[0].Points.DataBindXY(x, y);
Chart1.Series[0].ChartType = SeriesChartType.Spline; // Here We Can Change Chart Type
Chart1.Series[0].Color = Color.Cyan;
Chart1.Series[0].BorderColor = Color.Black;
Chart1.Series[0].BorderWidth = 5;
Chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
Chart1.Series[0].MarkerBorderWidth = 5;
Chart1.Legends[0].Enabled = false;
Chart1.Series[0].IsValueShownAsLabel = true;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -90;
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font("Calibri", 12f, System.Drawing.FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.ForeColor = Color.DeepPink;
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.Font = new Font("Calibri", 12f, System.Drawing.FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisY.LabelStyle.ForeColor = Color.Green;
Chart1.ChartAreas["ChartArea1"].AxisX.Title = "Students";
Chart1.ChartAreas["ChartArea1"].AxisX.TitleAlignment = StringAlignment.Center;
Chart1.ChartAreas["ChartArea1"].AxisX.TitleForeColor = Color.DarkBlue;
Chart1.ChartAreas["ChartArea1"].AxisX.TitleFont = new Font("Calibri", 16f, System.Drawing.FontStyle.Bold);
Chart1.ChartAreas["ChartArea1"].AxisY.Title = "Marks";
Chart1.ChartAreas["ChartArea1"].AxisY.TitleAlignment = StringAlignment.Center;
Chart1.ChartAreas["ChartArea1"].AxisY.TitleForeColor = Color.Orange;
Chart1.ChartAreas["ChartArea1"].AxisY.TitleFont = new Font("Calibri", 16f, System.Drawing.FontStyle.Bold);
con.Close();
}