ArcGIS Engine 渲染----饼图

private RgbColor GetRgbColor(int red, int green, int blue) 3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)$?3qsQ\c| pF
        {
aD(r2Hv&|Ae0            RgbColor rgbColor = new RgbColorClass(); 3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)9vY']pF
            rgbColor.Red = red;
b _w ?&R+ldA!G0            rgbColor.Green = green; 3sNews.Net——3S社区&资讯平台(GIS|RS|GPS) ct"QfaQ/Q
            rgbColor.Blue = blue;

            return rgbColor;
%Vf B-Ok+i#vp0        }

        private void btnPieChart_Click(object sender, EventArgs e)
*l(e"J/^4R1C0        {3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)?[r{`
            IMap pMap = new MapClass();
;A2g;s8[q+\&d0e:D lJ0            IFeatureLayer pFLayer = (IFeatureLayer)axMapControl1.get_Layer(0);
m['O,rL.?5t'^0            IGeoFeatureLayer pGeoFeaLayer = (IGeoFeatureLayer)pFLayer;

            IChartRenderer pChartRenderer = new ChartRendererClass();

            // Set up the field to draw charts

            IRendererFields pRenderFields = (IRendererFields)pChartRenderer;
T8AEE/S+OC\@+_o y0            pRenderFields.AddField("Pop_cntry", null);3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)%H[\&iB`{DG*F
            IPieChartRenderer pPieChartRender = (IPieChartRenderer)pChartRenderer;

            //Calculate the max value of the data field to scale the chart


H"fcPl$F0            //ICursor pCursor = new CursorClass();

            IQueryFilter pQueryFilter = new QueryFilterClass();
S^+s\2W/k'p;e&K0            //IRowBuffer pRow = new RowBufferClass();
"w ?f b-YS#X _A0            ITable pTable = (ITable)pGeoFeaLayer;
'X8qcz*HR,b0            pQueryFilter.AddField("Pop_cntry");
SG9o,iF1G2eb0            ICursor pCursor = pTable.Search(pQueryFilter, true);

            int  fieldIndex;
4A&zWsS5O}:y0            double MaxValue;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)] APp\
            bool firstValue;
hh(Le)D0            double fieldValue;

            fieldIndex = pTable.FindField("Pop_cntry");3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)9OWjq7~[/C\
            firstValue = true;
2k3SV X_}Nj'b0            MaxValue = 0;

3sNews.Net——3S社区&资讯平台(GIS|RS|GPS) TM-`e&E1]&`1g
            IRowBuffer pRow = pCursor.NextRow();3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)kU-h.mIs;N%U1tMAa
            while (pRow != null)3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)X{ F D ~
            {
&b:t B:Dj U0                fieldValue =(double) pRow.get_Value(fieldIndex);3sNews.Net——3S社区&资讯平台(GIS|RS|GPS);P e;q5a*yT
                if (firstValue)
,Gt.\#Lz0                {
(T%k*bG iAM6w:l0                    MaxValue = fieldValue;
gcdh1B#y1hV,tRw U0                    firstValue = false;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)'Y-d9p Cw m"J$S
                }

                if (fieldValue > MaxValue)3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)*Z1~{Pc3V
                {
:G'g s;VB a6@6~0                    MaxValue = fieldValue;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)*W pC.E?j
                }3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)BlX%Q-K.L.?O*v
                pRow = pCursor.NextRow();3sNews.Net——3S社区&资讯平台(GIS|RS|GPS):D8VAFdZ_U
            }

            IPieChartSymbol pPiechartSymbol = new Pie          ChartSymbolClass();
(w3@1tc%R"g&_0            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

            IChartSymbol pChartSymbol = (IChartSymbol)pPiechartSymbol;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)7SZB`.M
            pPiechartSymbol.Clockwise = true;
'T6QdYp&G)R8@0            pPiechartSymbol.UseOutline = true;

            ILineSymbol pOutLine = new SimpleLineSymbolClass();
N(B,b8a!{2o0            pOutLine.Color = GetRgbColor(255,0,255);
\-N.rwA&P"Lk0            pOutLine.Width = 1;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)atP~ |Eu`R
            pPiechartSymbol.Outline = pOutLine;

            IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pPiechartSymbol;

            //finally

            pChartSymbol.MaxValue = MaxValue;

            pMarkerSymbol.Size = 16;

            ISymbolArray pSymbolArray = (ISymbolArray)pPiechartSymbol;
}'E+N? S0            pFillSymbol.Color = GetRgbColor(213,212,252);

            pFillSymbol.Outline = pOutLine;
&^^3bI%wM0            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            //set up the background

            pFillSymbol.Color = GetRgbColor(239,228,190);
[r5B,j%[0            pChartRenderer.BaseSymbol = (ISymbol)pFillSymbol;

            pChartRenderer.UseOverposter = false;

            pPieChartRender.MinSize = 6;

            pPieChartRender.MinValue = 453588;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS) T8c7}.]:ZF)W
            pPieChartRender.FlanneryCompensation = false;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)VvM9Zq[&d_A%|
            pPieChartRender.ProportionalBySum = true;

            pChartRenderer.ChartSymbol = (IChartSymbol)pPiechartSymbol;3sNews.Net——3S社区&资讯平台(GIS|RS|GPS)H:w1H6[?QC
            pChartRenderer.CreateLegend();
]Xy$jG To0            pGeoFeaLayer.Renderer =(IFeatureRenderer) pChartRenderer;

            this.axLicenseControl1.Refresh();         

         }

你可能感兴趣的:(ArcGis Engine)