ArcGIS Engine 10 开发手册(7-11)ArcGIS Engine中饼图的调用
发布时间: 2018-01-06
所属分类: ArcGIS Engine 10 开发手册
本文介绍使用ArcGIS Engine生成饼图的方法。
ArcGIS Engine生成饼图示例代码
代码如下:
public PieRender (AxMapControl pMapcontrol, IFeatureLayer pFtLayer, string pFieldName1, string pFieldName2)
{
IGeoFeatureLayer pGeoFeaLayer = (IGeoFeatureLayer) pFtLayer;
IChartRenderer pChartRenderer = new ChartRendererClass ();
// Set up the field to draw charts
IRendererFields pRenderFields = (IRendererFields) pChartRenderer;
pRenderFields.AddField (pFieldName1, pFieldName1);
pRenderFields.AddField (pFieldName2, pFieldName2);
IPieChartRenderer pPieChartRender = (IPieChartRenderer) pChartRenderer;
//计算最大值部分有待补充////////////////////////////////////
//Calculate the max value of the data field to scale the chart
//ICursor pCursor = new CursorClass();
IQueryFilter pQueryFilter = new QueryFilterClass ();
//IRowBuffer pRow = new RowBufferClass();
ITable pTable = (ITable) pGeoFeaLayer;
pQueryFilter.AddField (pFieldName1);
ICursor pCursor = pTable.Search (pQueryFilter, true);
IDataStatistics pDataStat = new DataStatisticsClass ();
IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search (null, false);
pDataStat.Cursor = pFtCursor as ICursor;
pDataStat.Field = pFieldName1;
double pMax = pDataStat.Statistics.Maximum;
IPieChartSymbol pPiechartSymbol = new PieChartSymbolClass ();
IFillSymbol pFillSymbol = new SimpleFillSymbolClass ();
IChartSymbol pChartSymbol = (IChartSymbol) pPiechartSymbol;
pPiechartSymbol.Clockwise = true;
pPiechartSymbol.UseOutline = true;
ILineSymbol pOutLine = new SimpleLineSymbolClass ();
pOutLine.Color = GetRGBColor (255, 0, 255);
pOutLine.Width = 1;
pPiechartSymbol.Outline = pOutLine;
IMarkerSymbol pMarkerSymbol = (IMarkerSymbol) pPiechartSymbol;
//finally
pChartSymbol.MaxValue = pMax;
pMarkerSymbol.Size = 16;
//像符号数组中添加 添加符号
ISymbolArray pSymbolArray = (ISymbolArray) pPiechartSymbol;
pFillSymbol.Color = GetRGBColor (213, 212, 252);
pFillSymbol.Outline = pOutLine;
pSymbolArray.AddSymbol ((ISymbol) pFillSymbol);
//////////////////////////
pFillSymbol.Color = GetRGBColor (183, 242, 122);
pFillSymbol.Outline = pOutLine;
pSymbolArray.AddSymbol ((ISymbol) pFillSymbol);
//set up the background
pFillSymbol.Color = GetRGBColor (239, 228, 190);
pChartRenderer.BaseSymbol = (ISymbol) pFillSymbol;
pChartRenderer.UseOverposter = false;
pPieChartRender.MinSize = 1;
pPieChartRender.MinValue = pDataStat.Statistics.Minimum;
pPieChartRender.FlanneryCompensation = false;
pPieChartRender.ProportionalBySum = true;
pChartRenderer.ChartSymbol = (IChartSymbol) pPiechartSymbol;
pChartRenderer.CreateLegend ();
pGeoFeaLayer.Renderer = (IFeatureRenderer) pChartRenderer;
pMapcontrol.ActiveView.Refresh ();
}
public IRgbColor GetRGBColor (int r, int g, int b)
{
IRgbColor pRGB;
pRGB = new RgbColorClass ();
pRGB.Red = r;
pRGB.Green = g;
pRGB.Blue = b;
return pRGB;
}
效果如图
ArcGIS Engine 10 开发手册全集
ArcGIS Engine 10 开发手册全集: ArcGIS Engine 10 开发手册
相关阅读
声明
1.本文所分享的所有需要用户下载使用的内容(包括但不限于软件、数据、图片)来自于网络或者麻辣GIS粉丝自行分享,版权归该下载资源的合法拥有者所有,如有侵权请第一时间联系本站删除。
2.下载内容仅限个人学习使用,请切勿用作商用等其他用途,否则后果自负。
手机阅读
公众号关注
知识星球
手机阅读
最新GIS干货
私享圈子