本文实例讲述了DevExpress中ChartControl实现柱状图演示的方法。分享给大家供大家参考。具体实现方法如下:
关键代码如下:
namespace DevExpressChart
{
public partial class winProduct : Form
{
public winProduct()
{
InitializeComponent();
}
static readonly string AccessFullPath = string.Format(@\"{0}\\Northwind.MDB\", AppDomain.CurrentDomain.BaseDirectory);
static DataTable ProductList = null;
AccessUtilsV2 AccessHelper = null;
private void winChat_Load(object sender, EventArgs e)
{
AccessHelper = new AccessUtilsV2(AccessFullPath);
ProductList = AccessHelper.ExecuteDataTable(\"select * from Products\", null);
BuilderDevChart();
}
private void BuilderDevChart()
{
if (ProductList != null)
{
Series _barSeries = new Series(\"测试\", ViewType.Bar);
_barSeries.ArgumentDataMember = \"ProductName\";//x轴
_barSeries.ValueDataMembers[0] = \"UnitPrice\";//Y轴
_barSeries.DataSource = ProductList;
_barSeries.AddDataFilter(\"CategoryID\", 4, DataFilterCondition.Equal);
_barSeries.SetColorEach(true);
chartControl1.Series.Add(_barSeries);
_barSeries.LegendPointOptions.PointView = PointView.ArgumentAndValues;
//chartControl1.SeriesDataMember = \"UnitPrice\";
//chartControl1.SeriesTemplate.ValueDataMembers[0] = \"UnitPrice\";
//chartControl1.SeriesTemplate.ArgumentDataMember = \"ProductName\";
//chartControl1.SeriesTemplate.ArgumentScaleType = ScaleType.Qualitative;
//chartControl1.SeriesTemplate.AddDataFilter(\"CategoryID\", 4, DataFilterCondition.Equal);
//chartControl1.SeriesTemplate.LegendPointOptions.PointView = PointView.ArgumentAndValues;
chartControl1.SetXLableAngle(-35);
chartControl1.SetCrosshair(true);
chartControl1.Legend.Direction = LegendDirection.LeftToRight;
chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Center;
chartControl1.Legend.AlignmentVertical = LegendAlignmentVertical.BottomOutside;
chartControl1.DataSource = ProductList;
chartControl1.AddTitle(\"Product List\");
//--------------------------
}
}
}
}
本文地址:https://www.stayed.cn/item/6337
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我