ChartControl 常用方法
本帖最后由 nbjjy 于 2013-8-31 19:16 编辑一般常用的绑定方法
private void BtnQuery_Click(object sender, EventArgs e)
{
string sql = @"SELECT codedevice.s_devid,issue.s_saledt,issue.f_execamt FROM issue,codedevice noholdlock
WHERE (issue.s_posid = codedevice.s_devid) and (issue.s_saledt = (select max(issue.s_saledt) from issue))";
DataSet ds = Common.SybaseHelper.Query(sql);
this.chartControl1.DataSource = ds.Tables;
this.chartControl1.SeriesDataMember = "s_saledt";
this.chartControl1.SeriesTemplate.ArgumentDataMember = "s_devid";
this.chartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "f_execamt" });
this.chartControl1.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
ChartTitle CT1 = new ChartTitle();
CT1.Text = "POS实时销售图";
chartControl1.Titles.Clear();
chartControl1.Titles.Add(CT1);
this.chartControl1.SeriesTemplate.View = new StackedBarSeriesView();
this.chartControl1.SeriesNameTemplate.BeginText = "销售日期: ";
}
柱形图
private void BtnQuery_Click(object sender, EventArgs e)
{
string sql = @"SELECT codedevice.s_devid,issue.s_saledt,issue.f_execamt FROM issue,codedevice noholdlock
WHERE (issue.s_posid = codedevice.s_devid) and (issue.s_saledt = (select max(issue.s_saledt) from issue))";
DataSet ds = Common.SybaseHelper.Query(sql);
this.chartControl1.Series.Clear();
Series S1 = new Series("柱状图", ViewType.Bar);
S1.ArgumentScaleType = ScaleType.Qualitative;
S1.DataSource = ds.Tables.DefaultView;
S1.ArgumentDataMember = "s_devid";
S1.ValueDataMembers = "f_execamt";
S1.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
this.chartControl1.Series.Add(S1);
ChartTitle CT1 = new ChartTitle();
CT1.Text = "POS实时销售图";
chartControl1.Titles.Clear();
chartControl1.Titles.Add(CT1);
this.chartControl1.Legend.Visible = false;//不现实指示图
}
饼形图
private void BtnQuery_Click(object sender, EventArgs e)
{
string sql = @"SELECT codedevice.s_devid,issue.s_saledt,issue.f_execamt FROM issue,codedevice noholdlock
WHERE (issue.s_posid = codedevice.s_devid) and (issue.s_saledt = (select max(issue.s_saledt) from issue))";
DataSet ds = Common.SybaseHelper.Query(sql);
Series Serices1 = new Series("饼形图 ", ViewType.Pie3D);
chartControl1.Series.Add(Serices1);
Serices1.DataSource = ds.Tables.DefaultView; ;
Serices1.ArgumentScaleType = ScaleType.Qualitative;
Serices1.ArgumentDataMember = "s_devid";
Serices1.ValueScaleType = ScaleType.Numerical;
Serices1.ValueDataMembers.AddRange(new string[] { "f_execamt" });
Serices1.PointOptions.PointView = PointView.ArgumentAndValues;
Serices1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
chartControl1.Visible = true;
}
今后如有更好的方法我再添加上去
页:
[1]