Beispiel #1
0
        //Create Legend
        public void CreateLegend()
        {
            clsSnippet pSnippet = new clsSnippet();

            //Create Legend Group
            m_pLegendGroup          = new LegendGroup();
            m_pLegendGroup.Heading  = m_strOriRenderField;
            m_pLegendGroup.Editable = true;
            m_pLegendGroup.Visible  = true;

            ILegendClass legendClass = new LegendClass();

            legendClass.Label = Math.Round(dblMaxValue, 0).ToString();

            IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass();

            //IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
            stackedChartSymbol.Width = 10;
            if (bln3Dfeature)
            {
                I3DChartSymbol p3DChartSymbol = stackedChartSymbol as I3DChartSymbol;
                p3DChartSymbol.Display3D = true;
                p3DChartSymbol.Thickness = 3;
            }
            //IMarkerSymbol markerSymbol = stackedChartSymbol as IMarkerSymbol;
            //markerSymbol.Size = 50;
            IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol;

            chartSymbol.MaxValue = dblMaxValue;

            ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray;
            //Stacked Symbol
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();

            fillSymbol.Color         = pSnippet.getRGB(255, 0, 0);
            fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            chartSymbol.set_Value(0, dblMaxUncern);

            //fillSymbol = new SimpleFillSymbolClass();
            //fillSymbol.Color = pSnippet.getRGB(255, 0, 0);
            //fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            //symbolArray.AddSymbol(fillSymbol as ISymbol);
            //chartSymbol.set_Value(1, dblMaxUncern);

            fillSymbol               = new SimpleFillSymbolClass();
            fillSymbol.Color         = pSnippet.getRGB(255, 255, 255);
            fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            chartSymbol.set_Value(1, dblMaxEstimate - dblMaxUncern);

            legendClass.Symbol = (ISymbol)chartSymbol;
            m_pLegendGroup.AddClass(legendClass);

            //Bounds
            legendClass       = new LegendClass();
            legendClass.Label = "Upper Bound";
            ISimpleFillSymbol pLegendUncerSymbol = new SimpleFillSymbol();

            pLegendUncerSymbol.Color         = pSnippet.getRGB(0, 0, 255);
            pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);

            legendClass.Symbol = (ISymbol)pLegendUncerSymbol;
            m_pLegendGroup.AddClass(legendClass);

            legendClass                      = new LegendClass();
            legendClass.Label                = "Lower Bound";
            pLegendUncerSymbol               = new SimpleFillSymbol();
            pLegendUncerSymbol.Color         = pSnippet.getRGB(255, 0, 0);
            pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);

            legendClass.Symbol = (ISymbol)pLegendUncerSymbol;
            m_pLegendGroup.AddClass(legendClass);
        }
Beispiel #2
0
        //Draw Symbols by features
        public void Draw(IFeatureCursor pFCursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
        {
            pFCursor = m_pFeatureClass.Search(m_pQueryFilter, true);
            clsSnippet pSnippet = new clsSnippet();

            IFeature pFeature = pFCursor.NextFeature();

            double dblValue    = 0;
            double dblUncern   = 0;
            double dblInterval = 0;

            IStackedChartSymbol barChartSymbol;
            IChartSymbol        chartSymbol;

            while (pFeature != null)
            {
                IFeatureDraw pFeatDraw = (IFeatureDraw)pFeature;

                dblValue  = Convert.ToDouble(pFeature.get_Value(intValueFldIdx));
                dblUncern = Convert.ToDouble(pFeature.get_Value(intUncerFldIdx));

                dblInterval = dblError * dblUncern;


                barChartSymbol = new StackedChartSymbolClass();

                barChartSymbol.Width = 10;

                if (bln3Dfeature)
                {
                    I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                    p3DChartSymbol.Display3D = true;
                    p3DChartSymbol.Thickness = 3;
                }

                //IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                //markerSymbol.Size = 50;
                chartSymbol          = barChartSymbol as IChartSymbol;
                chartSymbol.MaxValue = dblMaxValue;


                ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                //Upper Error Symbol
                IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(0, 0, 255);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(0, dblInterval);

                //Lower Error
                fillSymbol               = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(255, 0, 0);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(1, dblInterval);

                //Value -Error to represent mean value
                fillSymbol               = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(255, 255, 255);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(2, dblValue - dblInterval);
                Display = m_pDisplay;
                Display.SetSymbol((ISymbol)chartSymbol);
                DrawPhase = esriDrawPhase.esriDPGeography;
                pFeatDraw.Draw(DrawPhase, Display, (ISymbol)chartSymbol, true,
                               null, esriDrawStyle.esriDSNormal);
                pFeature = pFCursor.NextFeature();
            }
        }
Beispiel #3
0
        //StackedChartSymbol
        //堆积图
        private void button6_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer featureLayer;
            ITable table;
            ICursor cursor;
            IRowBuffer rowBuffer;
            //设置渲染要素
            string field1 = "sqmi";
            string field2 = "sqkm";
            //获取渲染图层
            geoFeatureLayer = getGeoLayer("Continents");
            featureLayer = geoFeatureLayer as IFeatureLayer;
            table = featureLayer as ITable;
            geoFeatureLayer.ScaleSymbols = true;
            IChartRenderer chartRenderer = new ChartRendererClass();
            IRendererFields rendererFields = chartRenderer as IRendererFields;
            rendererFields.AddField(field1, field1);
            rendererFields.AddField(field2, field2);
            int[] fieldIndexs = new int[2];
            fieldIndexs[0] = table.FindField(field1);
            fieldIndexs[1] = table.FindField(field2);
            //获取要素最大值
            double fieldValue = 0.0, maxValue = 0.0;
            cursor = table.Search(null, true);
            rowBuffer = cursor.NextRow();
            while (rowBuffer != null)
            {
                for (int i = 0; i < 2; i++)
                {
                    fieldValue = double.Parse(rowBuffer.get_Value(fieldIndexs[i]).ToString());
                    if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
                rowBuffer = cursor.NextRow();
            }
            //创建累积排列符号
            IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass();

            stackedChartSymbol.Width = 10;
            IMarkerSymbol markerSymbol = stackedChartSymbol as IMarkerSymbol;
            markerSymbol.Size = 50;
            IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol;
            chartSymbol.MaxValue = maxValue;
            //添加渲染符号
            ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray;
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();
            fillSymbol.Color = getRGB(255, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            fillSymbol = new SimpleFillSymbolClass();
            fillSymbol.Color = getRGB(0, 255, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            //设置柱状图符号
            chartRenderer.ChartSymbol = stackedChartSymbol as IChartSymbol;
            fillSymbol = new SimpleFillSymbolClass();
            fillSymbol.Color = getRGB(0, 0, 255);
            chartRenderer.BaseSymbol = fillSymbol as ISymbol;
            chartRenderer.UseOverposter = false;
            //创建图例
            chartRenderer.CreateLegend();
            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
            this.axMapControl1.Refresh();
        }
Beispiel #4
0
        private void btnStackedChartRender_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer pGeoFeatLyr = (IGeoFeatureLayer)this.mainMapControl.get_Layer(0);

            double p1, p2, max;//比较制作专题图所用两个字段的最大值的最大
            ICursor pCursor = (ICursor)pGeoFeatLyr.Search(null, true);
            IDataStatistics pDataStatistics = new DataStatisticsClass();
            pDataStatistics.Cursor = pCursor;
            pDataStatistics.Field = "GDP_1999(";
            p1 = pDataStatistics.Statistics.Maximum;
            pCursor = (ICursor)pGeoFeatLyr.Search(null, true);//重新设置Cursor,为什么一定要这样?
            //pDataStatistics.Cursor = null;
            pDataStatistics.Cursor = pCursor;
            pDataStatistics.Field = "GDP_1994(";
            p2 = pDataStatistics.Statistics.Maximum;
            //MessageBox.Show(p1.ToString() + "\n" + p2.ToString());
            max = p1 > p2 ? p1 : p2;

            //以下创造3个SimpleFillSymbol,供下面使用
            ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
            pSimpleFillSymbol.Color = getRGBColor(255, 0, 0);
            pSimpleFillSymbol.Outline = null;
            ISimpleFillSymbol pSimpleFillSymbol2 = new SimpleFillSymbolClass();
            pSimpleFillSymbol2.Color = getRGBColor(0, 0, 255);
            pSimpleFillSymbol2.Outline = null;
            ISimpleFillSymbol pSimpleFillSymbol3 = new SimpleFillSymbolClass();
            pSimpleFillSymbol3.Color = getRGBColor(0, 255, 0);

            //以下代码设置StackedChart符号,和StackedChart符号的各符号
            IStackedChartSymbol pStackedChartSymbol = new StackedChartSymbolClass();//Stached符号
            pStackedChartSymbol.Width = 6;//宽度
            pStackedChartSymbol.Fixed = false;//不固定长度
            IChartSymbol pChartSymbol = pStackedChartSymbol as IChartSymbol;
            pChartSymbol.MaxValue = max;//必须
            IMarkerSymbol pMarkerSymbol = pStackedChartSymbol as IMarkerSymbol;
            pMarkerSymbol.Size = 60;//符号大小
            ISymbolArray pSymbolArray = pStackedChartSymbol as ISymbolArray;//SymbolArray
            pSymbolArray.AddSymbol((ISymbol)pSimpleFillSymbol);//添加符号
            pSymbolArray.AddSymbol((ISymbol)pSimpleFillSymbol2);//添加符号

            //以下代码设置着色对象
            IChartRenderer pChartRenderer = new ChartRendererClass();
            IRendererFields pRendererFields = pChartRenderer as IRendererFields;
            pRendererFields.AddField("GDP_1999(", "GDP_1999(");
            pRendererFields.AddField("GDP_1994(", "GDP_1994(");
            pChartRenderer.ChartSymbol = (IChartSymbol)pStackedChartSymbol;//设置符号
            pChartRenderer.Label = "GDP";
            pChartRenderer.BaseSymbol = pSimpleFillSymbol3 as ISymbol;//背景
            pChartRenderer.UseOverposter = true;//防止重叠
            pChartRenderer.CreateLegend();//创造图例,关键!!!!!!!!!

            pGeoFeatLyr.Renderer = (IFeatureRenderer)pChartRenderer;
            this.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            this.axTOCControl.Update();
        }
Beispiel #5
0
        //StackedChartSymbol
        private void button6_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer geoFeatureLayer;
            IFeatureLayer    featureLayer;
            ITable           table;
            ICursor          cursor;
            IRowBuffer       rowBuffer;
            //设置渲染要素
            string field1 = "sqmi";
            string field2 = "sqkm";

            //获取渲染图层
            geoFeatureLayer = getGeoLayer("Continents");
            featureLayer    = geoFeatureLayer as IFeatureLayer;
            table           = featureLayer as ITable;
            geoFeatureLayer.ScaleSymbols = true;
            IChartRenderer  chartRenderer  = new ChartRendererClass();
            IRendererFields rendererFields = chartRenderer as IRendererFields;

            rendererFields.AddField(field1, field1);
            rendererFields.AddField(field2, field2);
            int[] fieldIndexs = new int[2];
            fieldIndexs[0] = table.FindField(field1);
            fieldIndexs[1] = table.FindField(field2);
            //获取要素最大值
            double fieldValue = 0.0, maxValue = 0.0;

            cursor    = table.Search(null, true);
            rowBuffer = cursor.NextRow();
            while (rowBuffer != null)
            {
                for (int i = 0; i < 2; i++)
                {
                    fieldValue = double.Parse(rowBuffer.get_Value(fieldIndexs[i]).ToString());
                    if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
                rowBuffer = cursor.NextRow();
            }
            //创建累积排列符号
            IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass();

            stackedChartSymbol.Width = 10;
            IMarkerSymbol markerSymbol             = stackedChartSymbol as IMarkerSymbol;

            markerSymbol.Size = 50;
            IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol;

            chartSymbol.MaxValue = maxValue;
            //添加渲染符号
            ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray;
            IFillSymbol  fillSymbol  = new SimpleFillSymbolClass();

            fillSymbol.Color = getRGB(255, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            fillSymbol       = new SimpleFillSymbolClass();
            fillSymbol.Color = getRGB(0, 255, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            //设置柱状图符号
            chartRenderer.ChartSymbol = stackedChartSymbol as IChartSymbol;
            fillSymbol                  = new SimpleFillSymbolClass();
            fillSymbol.Color            = getRGB(0, 0, 255);
            chartRenderer.BaseSymbol    = fillSymbol as ISymbol;
            chartRenderer.UseOverposter = false;
            //创建图例
            chartRenderer.CreateLegend();
            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
            this.axMapControl1.Refresh();
        }
Beispiel #6
0
 private void method_4()
 {
     if (this.igeoFeatureLayer_0 == null)
     {
         this.ichartRenderer_0 = null;
     }
     else
     {
         IChartRenderer pInObject = this.igeoFeatureLayer_0.Renderer as IChartRenderer;
         if (pInObject == null)
         {
             if (this.ichartRenderer_0 == null)
             {
                 this.ichartRenderer_0 = new ChartRendererClass();
                 if (this.int_0 == 0)
                 {
                     this.ichartRenderer_0.ChartSymbol = new PieChartSymbolClass();
                 }
                 else if (this.int_0 == 1)
                 {
                     this.ichartRenderer_0.ChartSymbol = new BarChartSymbolClass();
                 }
                 else
                 {
                     this.ichartRenderer_0.ChartSymbol = new StackedChartSymbolClass();
                 }
                 (this.ichartRenderer_0.ChartSymbol as IMarkerSymbol).Size = 32.0;
             }
         }
         else
         {
             IObjectCopy copy = new ObjectCopyClass();
             this.ichartRenderer_0 = copy.Copy(pInObject) as IChartRenderer;
             IChartSymbol chartSymbol = this.ichartRenderer_0.ChartSymbol;
             IChartSymbol symbol2     = null;
             if (this.int_0 == 0)
             {
                 if (!(chartSymbol is IPieChartSymbol))
                 {
                     symbol2 = new PieChartSymbolClass();
                 }
             }
             else if (this.int_0 == 1)
             {
                 if (!(chartSymbol is IBarChartSymbol))
                 {
                     symbol2 = new BarChartSymbolClass();
                 }
             }
             else if ((this.int_0 == 2) && !(chartSymbol is IStackedChartSymbol))
             {
                 symbol2 = new StackedChartSymbolClass();
             }
             if (symbol2 != null)
             {
                 ISymbolArray array = chartSymbol as ISymbolArray;
                 for (int i = 0; i < array.SymbolCount; i++)
                 {
                     (symbol2 as ISymbolArray).AddSymbol(array.get_Symbol(i));
                 }
                 this.ichartRenderer_0.ChartSymbol = symbol2;
             }
         }
     }
 }