我有圖表與列類型(2系列):
- 一個系列爲男性。
- 一個女系列。
一切都很好,但我想設置X1,在底部X2標籤(X軸):更改X軸標籤的位置與2系列
我想把[單位#3333和單位#0099]在底部,[單元#1111和單元#555]
可能嗎?
下面的代碼(CS文件):
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;
namespace PCMD.AssignTransferSystem.web.Managers
{
public partial class ColumnChart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.IsClustered = true;
Chart1.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit = false;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.PointDepth = 20;
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Perspective = 0;
SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=AssignTransferDB;Integrated Security=True");
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
string cmdstr = "select * from ReqUnitsByGender"; // View in DB
cmd.CommandText = cmdstr;
SqlDataReader Dr = cmd.ExecuteReader();
Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
Chart1.ChartAreas["ChartArea1"].AxisX2.Interval = 1;
//Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font = new Font("Arial", 16);
//Chart1.ChartAreas["ChartArea1"].AxisX2.LabelStyle.Font = new Font("Arial", 16);
//Chart1.Series["male"].IsValueShownAsLabel = true;
//Chart1.Series["female"].IsValueShownAsLabel = true;
//Chart1.Series["male"]["LabelStyle"] = "Bottom";
//Chart1.Series["female"]["LabelStyle"] = "Bottom";
//Chart1.Series["male"]["BarLabelStyle"] = "Bottom";
//Chart1.Series["female"]["BarLabelStyle"] = "Bottom";
while (Dr.Read())
{
if (Dr["Gender"].ToString()=="True")
{
Chart1.Series["male"].Points.AddXY(Dr["UnitName"].ToString(), Dr["CountRequest"].ToString());
Chart1.Series["male"].XAxisType = AxisType.Primary;
}
if (Dr["Gender"].ToString() == "False")
{
Chart1.Series["female"].Points.AddXY(Dr["UnitName"].ToString(), Dr["CountRequest"].ToString());
Chart1.Series["female"].XAxisType = AxisType.Secondary;
}
}
conn.Close();
}
}
}
發佈您的代碼,瞭解如何設置圖表。 – mmathis 2014-10-02 13:58:59
你可以在答案部分看到我的代碼bro @mmathis – 2014-10-02 19:51:58
謝謝。但是,您的代碼不是答案,因此請編輯您的問題並在其中發佈代碼,然後使用您的代碼刪除答案。 – mmathis 2014-10-02 20:17:02