显示样式如图:
源码:(由于此代码为项目中应用的部分代码,大家借鉴即可,有些接口是GIS技术的ArcEngine函数实现,非GIS技术人可不用追究)
/// <summary>
/// 显示柱状图
/// </summary>
/// <param name="dt"></param>
private void ShowBarChart(DataTable dt)
{
this.chartControl.Series.Clear();
//创建Serious
for (int i = 0; i < dt.Rows.Count;i++ )
{
this.chartControl.Series.Add(dt.Rows[i][0].ToString(), DevExpress.XtraCharts.ViewType.Bar);
int seriousIndex = GetSeriousIndex(dt.Rows[i][0].ToString());
DevExpress.XtraCharts.SideBySideBarSeriesView pSideBySideBarSeriesView = new DevExpress.XtraCharts.SideBySideBarSeriesView();
IColor pColor = Common.AELib.CLayer.GetLayerColorByName(dt.Rows[i][0].ToString(), _pMap);
IRgbColor pRgbColor=pColor as IRgbColor;
pSideBySideBarSeriesView.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(pRgbColor.Red)))), ((int)(((byte)(pRgbColor.Green)))), ((int)(((byte)(pRgbColor.Blue)))));
pSideBySideBarSeriesView.FillStyle.FillMode = DevExpress.XtraCharts.FillMode.Solid;
pSideBySideBarSeriesView.Transparency = ((byte)(0));
this.chartControl.Series[seriousIndex].View = pSideBySideBarSeriesView;
DataTable tempdt = new DataTable();
tempdt = dt.Copy();
tempdt.Rows.Clear();
tempdt.ImportRow(dt.Rows[i]);
this.chartControl.Series[seriousIndex].DataSource = tempdt.DefaultView;
this.chartControl.Series[seriousIndex].ArgumentDataMember = tempdt.Columns[0].ToString();//X方向
this.chartControl.Series[seriousIndex].ValueDataMembers[0] = tempdt.Columns[1].ToString();//Y方向
}
this.chartControl.Refresh();
}
/// <summary>
/// 获得特定名称的Serious Index编号
/// </summary>
/// <param name="layerName"></param>
/// <returns></returns>
private int GetSeriousIndex(string layerName)
{
for (int i = 0; i < this.chartControl.Series.Count; i++)
{
if (this.chartControl.Series[i].Name == layerName)
return i;
}
return -1;
}