能给个C#中利用Chart组件绘制条形图的例子么?急急急急!!!
发布网友
发布时间:2022-05-01 06:43
我来回答
共3个回答
热心网友
时间:2022-06-25 16:41
public partial class StatisticsForm : Form
{
public StatisticsForm(ResultForm parent,int passNumber,int errorNumber)
{
InitializeComponent();
this.parentForm = parent;
this.TitleLab.Text = "This is the Statistics of all the cases you just run";
this.passNumber = passNumber;
this.errorNumber = errorNumber;
this.DataChart.Series[0].LegendText = "Pass";
this.DataChart.Series.Add("Fail");
this.DataChart.Series[0].Color = Color.Blue;
this.DataChart.Series[1].Color = Color.Red;
this.DataChart.Series[0].IsValueShownAsLabel = true;
this.DataChart.Series[0].MarkerStyle = MarkerStyle.Diamond;
this.DataChart.Series[0].MarkerSize = 0;
this.DataChart.Series[1].IsValueShownAsLabel = true;
this.DataChart.Series[1].MarkerStyle = MarkerStyle.Diamond;
this.DataChart.Series[1].MarkerSize = 0;
DataTable dt = default(DataTable);
dt = CreateDataTable();
this.DataChart.DataSource = dt;
this.DataChart.Series[0].YValueMembers = "Volume1";
this.DataChart.Series[1].YValueMembers = "Volume2";
this.DataChart.DataBind();
}
private ResultForm parentForm;
private int passNumber;
private int errorNumber;
private void CloseBut_Click(object sender, EventArgs e)
{
this.Close();
}
private DataTable CreateDataTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("Volume1");
dt.Columns.Add("Volume2");
DataRow dr;
dr = dt.NewRow();
dr["Volume1"] = this.passNumber;
dr["Volume2"] = this.errorNumber;
dt.Rows.Add(dr);
return dt;
}
热心网友
时间:2022-06-25 16:41
office里面自带了一个条形码控件barcode,可以引用进来的,貌似还不错,可以用这个。追问我问的是用VS2010中的Chart组件怎么实现?
追答看错问题了
热心网友
时间:2022-06-25 16:42
MSDN上有
参考资料:http://archive.msdn.microsoft.com/mschart