注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

快乐小屋

 
 
 

日志

 
 

AE+C#+符号化-饼状图  

2013-04-28 11:58:45|  分类: ArcGIS Engine开 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

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;

 

 

        }

}

 


  评论这张
 
阅读(348)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018