AnsweredAssumed Answered

Setting Field in Symbology Properties

Question asked by AdrianK on Jul 27, 2015
Latest reply on Nov 10, 2015 by AdrianK

Hi

 

I am programmatically rendering a feature layer in ArcMap but I can't set the Field property in the Symbology properties form. This results in the layer having the correct render/breaks/legend settings but the on screen render is wrong. When I open the Symbology tab the Field isn't set. When I do select the field the classification is reset. The focus field is actually from a linked table. Any suggestions? Below is the code I have for rendering the layer.

I'm using ArcGIS 10.2.2; Windows 7;VS2010 Express. Feature layer is in a file geodatabase along with a linked table.

 

symbology_set_field.png

 

Regards

 

Adrian

    
public void ClassifyLayer(ref IFeatureLayer pFL, ITable pTable)
    
{


        
IGeoFeatureLayer pGFLyr = (IGeoFeatureLayer)pFL;
        
object dataValues;
        
object dataFrequencies;
        
ISimpleLineSymbol pLineFillSymbol;
        
IClassBreaksUIProperties pClassBreaksUIProperties;
        
IFeatureRenderer ifr = pGFLyr.Renderer;
        
IClassBreaksRenderer pClassBreaksRenderer = (IClassBreaksRenderer)ifr;
        
IDataSampling ds = (IDataSampling)pClassBreaksRenderer;
        
ITableHistogram pTH = (ITableHistogram)new TableHistogram();



        
pTH.Field = "IDX";
        
pTH.Table = pTable;
        
ds.MaxSampleSize = 1000000;
        
pTH.Sampling = ds;
        
IHistogram pHist = (IHistogram)pTH;
        
pHist.GetHistogram(out dataValues, out dataFrequencies);


      
 
        
IClassify pClassify  = new QuantileClass();
        
double[] classes;
       
 


        
pClassify.SetHistogramData(dataValues, dataFrequencies);
        
pClassify.Classify(10);
        
classes = (double[])pClassify.ClassBreaks;
        
pClassBreaksRenderer.BreakCount = classes.Length - 1;
        
pClassBreaksRenderer.Field = pTH.Field;
        
pClassBreaksRenderer.MinimumBreak = classes[0];
   
 
    
//Spectrum-Full Bright   
 
        
IMultiPartColorRamp pMultiColourRamp = GetSpectrumRamp(10);
        
bool rampcreated = false;
        
IEnumColors pColors = pMultiColourRamp.Colors;


        
for (int i = 0; i < pClassBreaksRenderer.BreakCount; i++)
        
{
            
pLineFillSymbol = new SimpleLineSymbol();
            
pLineFillSymbol.Color = pColors.Next();
            
pClassBreaksRenderer.Symbol[i] = (ISymbol)pLineFillSymbol;
            
pClassBreaksRenderer.set_Break(i,classes[i + 1]);
            
pClassBreaksRenderer.Label[i] = ((Single)(classes[i])).ToString() + " - " + ((Single)(classes[i + 1])).ToString();
        
}


        
pClassBreaksUIProperties = (IClassBreaksUIProperties)pClassBreaksRenderer;
        
pClassBreaksUIProperties.Method = pClassify.ClassID;
        
pClassBreaksUIProperties.ColorRamp = "Spectrum-Full Bright";
       
 
        
for (int i = 1; i < pClassBreaksRenderer.BreakCount; i++)
        
{
            
pClassBreaksUIProperties.set_LowBreak(i, pClassBreaksRenderer.Break[i - 1]);
        
}
       
 
        
pClassBreaksUIProperties.ShowClassGaps = true;


        
pGFLyr.Renderer = (IFeatureRenderer)pClassBreaksRenderer;
        
IRendererPropertyPage pRendererPropPage = (IRendererPropertyPage)new GraduatedColorPropertyPage();
        
pGFLyr.RendererPropertyPageClassID = pRendererPropPage.ClassID;


        
pMxDoc.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFL, null);
        
pMxDoc.UpdateContents();


    
}


 

Message was edited by: Adrian Kitchingman As requested; attempted syntax highlighting for C#  though couldn't stop formatting change and extra rows

Outcomes