ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / FeatureLayer Class / SetRenderer Method / SetRenderer(CIMRenderer) Method
Your custom renderer that will be used to draw features of the feature layer.
Example

In This Topic
    SetRenderer(CIMRenderer) Method
    In This Topic
    Specifies the feature layer's renderer object which determines how the layer draws. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetRenderer( 
       CIMRenderer renderer
    )
    Public Overloads Sub SetRenderer( _
       ByVal renderer As CIMRenderer _
    ) 

    Parameters

    renderer
    Your custom renderer that will be used to draw features of the feature layer.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Cannot set renderer for layer.
    Remarks
    Use CanSetRenderer to determine if the renderer is valid for the layer before updating it.
    Use FeatureLayer.CreateRenderer to create a new renderer.
    Example
    Modify renderer using Arcade
    {
      await QueuedTask.Run(() =>
      {
        // GetRenderer from Layer (assumes it is a unique value renderer)
        if (featureLayer.GetRenderer() is not CIMUniqueValueRenderer uvRenderer)
        {
          // not a unique value renderer, leave
          return;
        }
        //layer has STATE_NAME field if using the community sample Data\Admin\AdminSample.aprx
        string expression = "if ($view.scale > 21000000) { return $feature.STATE_NAME } else { return 'All' }";
        CIMExpressionInfo updatedExpressionInfo = new()
        {
          Expression = expression,
          Title = "Custom" // can be any string used for UI purpose.
        };
        //set the renderer's expression
        uvRenderer.ValueExpressionInfo = updatedExpressionInfo;
    
        //SetRenderer on Layer
        featureLayer.SetRenderer(uvRenderer);
      });
    }
    How to set symbol for a feature layer symbolized with simple renderer
    {
      await QueuedTask.Run(() =>
      {
      //Get simple renderer from the feature layer
      CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
      if (currentRenderer == null)
      {
        return;
      }
    
      //Set symbol's real world setting to be the same as that of the feature layer
      symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
      //Update the symbol of the current simple renderer
      currentRenderer.Symbol = symbol.MakeSymbolReference();
      //Update the feature layer renderer
        featureLayer.SetRenderer(currentRenderer);
      });
    }
    How to apply a symbol from style to a feature layer
    {
      await QueuedTask.Run(() =>
      {
      //Get simple renderer from the feature layer
      CIMSimpleRenderer currentRenderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
      if (currentRenderer == null)
      {
        return;
      }
      //Get symbol from the SymbolStyleItem
      CIMSymbol symbolToApply = symbolStyleItem.Symbol;
    
      //Set symbol's real world setting to be the same as that of the feature layer
      symbolToApply.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
      //Update the symbol of the current simple renderer
      currentRenderer.Symbol = symbolToApply.MakeSymbolReference();
      //Update the feature layer renderer
        featureLayer.SetRenderer(currentRenderer);
      });
    }
    How to apply a point symbol from a style to a feature layer
    {
          //Get the ArcGIS 2D System style from the Project
          var arcGIS2DStyle =
    Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
    
          await QueuedTask.Run(() =>
          {
          //Search for the symbolName style items within the ArcGIS 2D style project item.
          var items = arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, "Circle 1");
    
          //Gets the CIMSymbol
          CIMSymbol symbolToUse = items.FirstOrDefault().Symbol;
    
          //Get the renderer of the point feature layer
          CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
          //Set symbol's real world setting to be the same as that of the feature layer
          symbolToUse.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes);
    
          //Apply the symbol to the feature layer's current renderer
          renderer.Symbol = symbolToUse.MakeSymbolReference();
    
          //Apply the renderer to the feature layer
            featureLayer.SetRenderer(renderer);
          });
        }
    How to apply a color ramp from a style to a feature layer
    {
      List<string> fields = new List<string>() { "Field1" };
      var project = Project.Current;
      await QueuedTask.Run(() =>
      {
        StyleProjectItem styleToUse =
          project.GetItems<StyleProjectItem>()
              .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)");
        if (style == null)
        {
          return;
        }
        var colorRampListFound = styleToUse.SearchColorRamps("Red-Gray (10 Classes)");
        if (colorRampListFound == null || colorRampListFound.Count == 0)
        {
          return;
        }
    
        CIMColorRamp cimColorRamp = null;
        CIMRenderer renderer = null;
    
        cimColorRamp = colorRampListFound[0].ColorRamp;
        var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp);
        renderer = featureLayer?.CreateRenderer(rendererDef);
        featureLayer?.SetRenderer(renderer);
      });
    }
    Apply Symbology to a layer from a Layer file
    {
      IEnumerable<FeatureLayer> featureLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
        .Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint);
      var layerFile = @"C:\Data\SDK\UniqueValuePointLayer.lyrx";
      foreach (var featureLayerToSymbolize in featureLayers)
      {
        //Get the Layer Document from the lyrx file
        var lyrDocFromLyrxFile = new LayerDocument(layerFile);
        var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument();
    
        //Get the renderer from the layer file
        var rendererFromLayerFile = ((CIMFeatureLayer)cimLyrDoc.LayerDefinitions[0]).Renderer as CIMUniqueValueRenderer;
    
        //Apply the renderer to the feature layer
        //Note: If working with a raster layer, use the SetColorizer method.
        featureLayerToSymbolize?.SetRenderer(rendererFromLayerFile);
      }
    }
    Set unique value renderer to the selected feature layer of the active map
    {
      await QueuedTask.Run(() =>
      {
      //field to be used to retrieve unique values
      var fields = new List<string> { "Type" };
      //constructing a point symbol as a template symbol
      CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(
          ColorFactory.Instance.GreenRGB, 16.0, SimpleMarkerStyle.Pushpin);
      CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference();
    
      //constructing renderer definition for unique value renderer
      UniqueValueRendererDefinition uniqueValueRendererDef =
    new UniqueValueRendererDefinition(fields, symbolPointTemplate);
    
      //creating a unique value renderer
      CIMUniqueValueRenderer uniqueValueRenderer = featureLayer.CreateRenderer(uniqueValueRendererDef) as CIMUniqueValueRenderer;
    
      //setting the renderer to the feature layer
      featureLayer.SetRenderer(uniqueValueRenderer);
      });
    }
    Create a UniqueValueRenderer to specify symbols to values
    {
      await QueuedTask.Run(() =>
      {
      //The goal is to construct the CIMUniqueValueRenderer which will be applied to the feature layer.
      // To do this, the following are the objects we need to set the renderer up with the fields and symbols.
      // As a reference, this is the USCities dataset. Snippet will create a unique value renderer that applies
      // specific symbols to all the cities in California and Alabama.  The rest of the cities will use a default symbol.
    
      // First create a "CIMUniqueValueClass" for the cities in Alabama.
      List<CIMUniqueValue> listUniqueValuesAlabama = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "Alabama" } } };
      CIMUniqueValueClass alabamaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "Alabama",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuesAlabama.ToArray()
      };
      // Create a "CIMUniqueValueClass" for the cities in California.
      List<CIMUniqueValue> listUniqueValuescalifornia = new List<CIMUniqueValue> { new CIMUniqueValue { FieldValues = new string[] { "California" } } };
      CIMUniqueValueClass californiaUniqueValueClass = new CIMUniqueValueClass
      {
        Editable = true,
        Label = "California",
        Patch = PatchShape.Default,
        Symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(),
        Visible = true,
        Values = listUniqueValuescalifornia.ToArray()
      };
      //Create a list of the above two CIMUniqueValueClasses
      List<CIMUniqueValueClass> listUniqueValueClasses = new List<CIMUniqueValueClass>
      {
                    alabamaUniqueValueClass, californiaUniqueValueClass
      };
      //Create a list of CIMUniqueValueGroup
      CIMUniqueValueGroup uvg = new CIMUniqueValueGroup
      {
        Classes = listUniqueValueClasses.ToArray(),
      };
      List<CIMUniqueValueGroup> listUniqueValueGroups = new List<CIMUniqueValueGroup> { uvg };
      //Create the CIMUniqueValueRenderer
      CIMUniqueValueRenderer uvr = new CIMUniqueValueRenderer
      {
        UseDefaultSymbol = true,
        DefaultLabel = "all other values",
        DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(),
        Groups = listUniqueValueGroups.ToArray(),
        Fields = new string[] { "STATE_NAME" }
      };
      //Set the feature layer's renderer.
      featureLayer.SetRenderer(uvr);
      });
    }
    Create a Heatmap Renderer
    {
      string colorBrewerSchemesName = "ArcGIS Colors";
      //Get the style project item that contains the color ramps
      //Refer to the Initialize region for an example of how to get a style item
      //and the color ramp from it.
      await QueuedTask.Run(() =>
      {
      //defining a heatmap renderer that uses values from Population field as the weights
      HeatMapRendererDefinition heatMapDef = new HeatMapRendererDefinition()
      {
        Radius = 20,
        WeightField = "Population",
        ColorRamp = colorRamp,
        RendereringQuality = 8,
        UpperLabel = "High Density",
        LowerLabel = "Low Density"
      };
      CIMHeatMapRenderer heatMapRndr = featureLayer.CreateRenderer(heatMapDef) as CIMHeatMapRenderer;
      featureLayer.SetRenderer(heatMapRndr);
      });
    }
    Use Arcade expression to create Class Breaks
    {
      var usaStatesLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>()
                     .FirstOrDefault(fl => fl.Name == "USA States");
      if (usaStatesLayer == null)
      {
        return;
      }
    
      await QueuedTask.Run(() =>
      {
      //Create a color ramp from red to blue
      var colorRampForPopulation = ColorFactory.Instance.ConstructColorRamp(
            ColorRampAlgorithm.LinearContinuous,
            ColorFactory.Instance.RedRGB, ColorFactory.Instance.BlueRGB);
    
      //This Arcade expression categorizes the POP2000 field in the usaStates layer
      //into Low, Medium, and High values
      var arcade = @"if ($feature.POP2000 < 1000000)
                       {return ""Low"";}" +
                   @"else if ($feature.POP2000 >= 100000 && $feature.POP2000 < 5000000)
                      {return ""Medium""; }" +
                    @"else if ($feature.POP2000 >= 5000000)
                      {return ""High"";}" +
                    @"else{return ""NA"";}";
      //Create the Arcade expression info
      CIMExpressionInfo arcadeExp = new CIMExpressionInfo();
      arcadeExp.Expression = arcade;
      arcadeExp.ReturnType = ExpressionReturnType.Default;
      arcadeExp.Title = "State Population Categorized";
      arcadeExp.Name = "USA States Population 2000";
    
      //Each population category is assigned a color from the color ramp and symbolized on the map
      // using a unique value renderer
      var uvr_desc = new UniqueValueRendererDefinition()
      {
        //ValueFields = new List<string> { "STATION" },
        ColorRamp = colorRampForPopulation,
        UseDefaultSymbol = true,
        ValuesLimit = 100,
        ArcadeExpression = arcadeExp.Expression
      };
      //Create the renderer and assign it to the layer
      var renderer = usaStatesLayer.CreateRenderer(uvr_desc);
      usaStatesLayer.SetRenderer(renderer);
      });
    }
    Create an unclassed Renderer
    {
      string colorBrewerSchemesName = "ArcGIS Colors";
      //Get the style project item that contains the color ramps
      //Refer to the Initialize region for an example of how to get a style item
      await QueuedTask.Run(() =>
      {
      CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 16.0, SimpleMarkerStyle.Diamond);
      CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference();
    
      //defining an unclassed renderer with custom upper and lower stops
      //all features with value >= 5,000,000 will be drawn with the upper color from the color ramp
      //all features with value <= 50,000 will be drawn with the lower color from the color ramp
      UnclassedColorsRendererDefinition unclassRndrDef = new UnclassedColorsRendererDefinition
                            ("Population", symbolPointTemplate, colorRamp, "Highest", "Lowest", 5000000, 50000)
      {
    
        //drawing features with null values with a different symbol
        ShowNullValues = true,
        NullValueLabel = "Unknown"
      };
      // Create a point symbol for null values
      CIMPointSymbol nullSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 16.0, SimpleMarkerStyle.Circle);
      unclassRndrDef.NullValueSymbol = nullSym.MakeSymbolReference();
      //Create the unclassed renderer using the definition
      CIMClassBreaksRenderer cbRndr = featureLayer.CreateRenderer(unclassRndrDef) as CIMClassBreaksRenderer;
      //Set the renderer to the feature layer
      featureLayer.SetRenderer(cbRndr);
      });
    }
    Create a Proportion Renderer with max and min symbol size capped
    {
      string colorBrewerSchemesName = "ArcGIS Colors";
      //Get the style project item that contains the color ramps
      //Refer to the Initialize region for an example of how to get a style item
      await QueuedTask.Run(() =>
      {
      //Creating a point symbol to be used as a template symbol for the proportional renderer
      CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle);
      CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference();
    
      //minimum symbol size is capped to 4 point while the maximum symbol size is set to 50 point
      //Creating a proportional renderer definition that uses the "Population" field
      ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", symbolPointTemplate, 4, 50, true)
      {
        //setting upper and lower size stops to stop symbols growing or shrinking beyond those thresholds
        UpperSizeStop = 5000000,  //features with values >= 5,000,000 will be drawn with maximum symbol size
        LowerSizeStop = 50000    //features with values <= 50,000 will be drawn with minimum symbol size
      };
      // Create a proportional renderer using the definition
      CIMProportionalRenderer propRndr = featureLayer.CreateRenderer(prDef) as CIMProportionalRenderer;
      // Set the renderer to the feature layer
      featureLayer.SetRenderer(propRndr);
      });
    }
    Create a True Proportion Renderer
    {
      string colorBrewerSchemesName = "ArcGIS Colors";
      //Get the style project item that contains the color ramps
      //Refer to the Initialize region for an example of how to get a style item
      await QueuedTask.Run(() =>
      {
      //Creating a point symbol to be used as a template symbol for the proportional renderer
      CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle);
      CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference();
    
      //Defining proportional renderer where size of symbol will be same as its value in field used in the renderer.
      ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", esriUnits.esriMeters, symbolPointTemplate, SymbolShapes.Square, ValueRepresentations.Radius);
      //Create a Proportional renderer using the definition
      CIMProportionalRenderer propRndr = featureLayer.CreateRenderer(prDef) as CIMProportionalRenderer;
      // Set the renderer to the feature layer
      featureLayer.SetRenderer(propRndr);
      });
    }
    Pie chart renderer for a feature layer
    /// <summary>
    /// Renders a feature layer using Pie chart symbols to represent data
    /// ![Pie chart renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/pie-chart.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      await QueuedTask.Run(() =>
      {
        //Fields to use for the pie chart slices
        var chartFields = new List<string>
        {
              "WHITE10",
               "BLACK10",
               "AMERIND10",
               "ASIAN10",
               "HISPPOP10",
               "HAMERIND10",
               "HWHITE10",
               "HASIAN10",
               "HPACIFIC10",
               "HBLACK10",
                "HOTHRACE10"
        };
    
        PieChartRendererDefinition pieChartRendererDefn = new PieChartRendererDefinition()
        {
          ChartFields = chartFields,
          ColorRamp = colorRamp,
          SizeOption = PieChartSizeOptions.Field,
          FieldName = "BLACK10",
          FixedSize = 36.89,
          DisplayIn3D = true,
          ShowOutline = true,
          Orientation = PieChartOrientation.CounterClockwise,
        };
        //Creates a "Renderer"
        var pieChartRenderer = featureLayer.CreateRenderer(pieChartRendererDefn);
    
        //Sets the renderer to the feature layer
        featureLayer.SetRenderer(pieChartRenderer);
      });
    }
    Bar Chart Value renderer for a feature layer
    /// <summary>
    /// Renders a feature layer using Bar chart symbols to represent data
    /// ![bar chart renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/bar-chart.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      var chartFields = new List<string>
        {
            "WHITE10",
              "BLACK10",
              "AMERIND10",
              "ASIAN10",
              "HISPPOP10",
              "HAMERIND10",
              "HWHITE10",
              "HASIAN10",
              "HPACIFIC10",
              "HBLACK10",
              "HOTHRACE10"
        };
      await QueuedTask.Run(() =>
      {
        BarChartRendererDefinition barChartRendererDefn = new BarChartRendererDefinition()
        {
          ChartFields = chartFields,
          BarWidth = 12,
          BarSpacing = 1,
          MaximumBarLength = 65,
          Orientation = ChartOrientation.Vertical,
          DisplayIn3D = true,
          ShowAxes = true,
          ColorRamp = colorRamp
    
        };
        //Creates a "Renderer"
        var barChartChartRenderer = featureLayer.CreateRenderer(barChartRendererDefn);
    
        //Sets the renderer to the feature layer
        featureLayer.SetRenderer(barChartChartRenderer);
      });
    }
    Stacked bar chart renderer for a feature layer
    /// <summary>
    /// Renders a feature layer using stacked bar chart symbols to represent data
    /// ![stacked bar chart renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/stacked-bar-chart.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      var chartFields = new List<string>
          {
              "WHITE10",
               "BLACK10",
               "AMERIND10",
               "ASIAN10",
               "HISPPOP10",
               "HAMERIND10",
               "HWHITE10",
               "HASIAN10",
               "HPACIFIC10",
               "HBLACK10",
                "HOTHRACE10"
          };
    
      StackedChartRendererDefinition barChartpieChartRendererDefn = new StackedChartRendererDefinition()
      {
        ChartFields = chartFields,
        SizeOption = StackChartSizeOptions.SumSelectedFields,
        Orientation = ChartOrientation.Horizontal,
        ShowOutline = true,
        DisplayIn3D = true,
        StackWidth = 8,
        StackLength = 25.87,
        ColorRamp = colorRamp
    
      };
      await QueuedTask.Run(() =>
      {
        //Creates a "Renderer"
        var stackedBarChartChartRenderer = featureLayer.CreateRenderer(barChartpieChartRendererDefn);
    
        //Sets the renderer to the feature layer
        featureLayer.SetRenderer(stackedBarChartChartRenderer);
      });
    }
    Class Breaks renderer with graduated colors.
    /// <summary>
    /// Renders a feature layer using graduated colors to draw quantities.
    /// ![cb-colors.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/cb-colors.png "Graduated colors with natural breaks renderer.")
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
    
      GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition()
      {
        ClassificationField = "NumericFieldInFeatureLayer",
        ClassificationMethod = ClassificationMethod.NaturalBreaks,
        BreakCount = 5,
        ColorRamp = colorRamp,
      };
      await QueuedTask.Run(() =>
      {
        CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef);
        featureLayer?.SetRenderer(renderer);
      });
    }
    Class Breaks renderer with graduated colors and outline
    /// <summary>
    /// Renders a feature layer using graduated colors to draw quantities. The outline width is varied based on attributes.
    /// ![graduatedColorOutline.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/graduatedColorOutline.png "Graduated colors with natural breaks renderer.")
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Gets the first numeric field of the feature layer
      var firstNumericFieldOfFeatureLayer = "NumericFieldInFeatureLayer";
      //Gets the min and max value of the field
      var minMax = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer);
      GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition()
      {
        ClassificationField = "NumericFieldInFeatureLayer",
        ClassificationMethod = ClassificationMethod.NaturalBreaks,
        BreakCount = 5,
        ColorRamp = colorRamp
      };
      CIMClassBreaksRenderer renderer = await QueuedTask.Run(() =>
        (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef));
      //Create array of CIMVisualVariables to hold the outline information.
      var visualVariables = new CIMVisualVariable[] {
                  new CIMSizeVisualVariable
                  {
                      ValueExpressionInfo = new CIMExpressionInfo
                      {
                         Title = "Custom",
                         Expression = "$feature.AREA",
                         ReturnType = ExpressionReturnType.Default
                      },
                      AuthoringInfo = new CIMVisualVariableAuthoringInfo
                      {
                          MinSliderValue = Convert.ToDouble(minMax.Item1),
                          MaxSliderValue = Convert.ToDouble(minMax.Item2),
                          ShowLegend = false,
                          Heading = firstNumericFieldOfFeatureLayer
                      },
                      VariableType = SizeVisualVariableType.Graduated,
                      Target = "outline",
                      MinSize = 1,
                      MaxSize = 13,
                      MinValue = Convert.ToDouble(minMax.Item1),
                      MaxValue = Convert.ToDouble(minMax.Item2)
                  },
    
              };
      renderer.VisualVariables = visualVariables;
      await QueuedTask.Run(() => featureLayer?.SetRenderer(renderer));
    }
    Class Breaks renderer with graduated symbols.
    /// <summary>
    /// Renders a feature layer using graduated symbols and natural breaks to draw quantities.
    /// ![cb-symbols.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/cb-symbols.png "Graduated symbols with natural breaks renderer.")
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      GraduatedSymbolsRendererDefinition gsDef = new GraduatedSymbolsRendererDefinition()
      {
        ClassificationField = "NumericFieldInFeatureLayer", //getting the first numeric field
        ClassificationMethod = ClassificationMethod.NaturalBreaks,
        SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(76, 230, 0)).MakeSymbolReference(),
        MinimumSymbolSize = 4,
        MaximumSymbolSize = 50,
        BreakCount = 5,
        ColorRamp = colorRamp, //getting a color ramp
      };
      await QueuedTask.Run(() =>
      {
        CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gsDef);
        featureLayer?.SetRenderer(renderer);
      });
    }
    UnClassed graduated color renderer.
    /// <summary>
    /// Renders a feature layer using an unclassed color gradient.
    /// ![cb-unclassed.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/cb-unclassed.png "Class breaks unclassed renderer.")
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Gets the first numeric field of the feature layer
      var firstNumericFieldOfFeatureLayer = "NumericFieldInFeatureLayer";
      //Gets the min and max value of the field
      //Refer to the GetFieldMinMax function below
      var labels = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer);
      UnclassedColorsRendererDefinition ucDef = new UnclassedColorsRendererDefinition()
      {
        Field = firstNumericFieldOfFeatureLayer,
        ColorRamp = colorRamp,
        LowerColorStop = Convert.ToDouble(labels.Item1),
        UpperColorStop = Convert.ToDouble(labels.Item2),
        UpperLabel = labels.Item2,
        LowerLabel = labels.Item1,
      };
      await QueuedTask.Run(() =>
      {
        CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(ucDef);
        featureLayer?.SetRenderer(renderer);
      });
    }
    Class Breaks renderer with Manual Intervals
    /// <summary>
    /// Renders a feature layer using graduated colors and manual intervals to draw quantities.
    /// ![cb-colors-manual-breaks.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/cb-colors-manual-breaks.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Change these class breaks to be appropriate for your data. These class breaks defined below apply to the US States feature class
      List<CIMClassBreak> listClassBreaks = new List<CIMClassBreak>
          {
              new CIMClassBreak
              {
                  Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB).MakeSymbolReference(),
                  UpperBound = 24228
              },
              new CIMClassBreak
              {
                  Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB).MakeSymbolReference(),
                  UpperBound = 67290
              },
              new CIMClassBreak
              {
                  Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB).MakeSymbolReference(),
                  UpperBound = 121757
              },
               new CIMClassBreak
              {
                  Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB).MakeSymbolReference(),
                  UpperBound = 264435
              },
                new CIMClassBreak
              {
                  Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB).MakeSymbolReference(),
                  UpperBound = 576594
              }
          };
      CIMClassBreaksRenderer cimClassBreakRenderer = new CIMClassBreaksRenderer
      {
        ClassBreakType = ClassBreakType.GraduatedColor,
        ClassificationMethod = ClassificationMethod.Manual,
        Field = "NumericFieldInLayer",
        //Important to add the Minimum break for your data to be classified correctly.
        //This is vital especially if you have data with negative values.
        //MinimumBreak =
        Breaks = listClassBreaks.ToArray()
      };
      await QueuedTask.Run(() => featureLayer?.SetRenderer(cimClassBreakRenderer));
    }
    Dot Density renderer.
    /// <summary>
    /// Renders a polygon feature layer with Dot Density symbols to represent quantities.
    /// ![Dot Density renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/dotDensity-renderer.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Define size of the dot to use for the renderer
      int dotSize = 3;
      //Check if the TOTPOP10 field exists
      int idxField = -1;
      idxField = await QueuedTask.Run(() =>
      {
        using var table = featureLayer.GetTable();
        var def = table.GetDefinition();
        return def.FindField("TOTPOP10");
      });
      // "TOTPOP10" field was not found
      if (idxField == -1)
      {
        return;
      }
    
      //array of fields to be represented in the renderer
      var valueFields = new List<string> { "TOTPOP10" };
      await QueuedTask.Run(() =>
      {
        //Create the DotDensityRendererDefinition object
        var dotDensityDef = new DotDensityRendererDefinition(valueFields, colorRamp,
                                                                        dotSize, 30000, "Dot", "people");
      //Create the renderer using the DotDensityRendererDefinition
      CIMDotDensityRenderer dotDensityRndr = (CIMDotDensityRenderer)featureLayer.CreateRenderer(dotDensityDef);
    
      //if you want to customize the dot symbol for the renderer, create a "DotDensitySymbol" which is an
      //Amalgamation of 3 symbol layers: CIMVectorMarker, CIMSolidFill and CIMSolidStroke
      //Define CIMVectorMarker layer
      var cimMarker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, dotSize);
      var dotDensityMarker = cimMarker as CIMVectorMarker;
      //Define the placement
      CIMMarkerPlacementInsidePolygon markerPlacement = new CIMMarkerPlacementInsidePolygon { Randomness = 100, GridType = PlacementGridType.RandomFixedQuantity, Clipping = PlacementClip.RemoveIfCenterOutsideBoundary };
      dotDensityMarker.MarkerPlacement = markerPlacement;
    
      //Define CIMSolidFill layer
      CIMSolidFill solidFill = new CIMSolidFill { Color = new CIMRGBColor { R = 249, G = 232, B = 189, Alpha = 50 } };
    
      //Define CIMSolidStroke
      CIMSolidStroke solidStroke = new CIMSolidStroke { Color = ColorFactory.Instance.GreyRGB, Width = .5 };
    
      //Create the amalgamated CIMPolygonSymbol that includes the 3 layers
      var dotDensitySymbol = new CIMPolygonSymbol
      {
        SymbolLayers = new CIMSymbolLayer[] { dotDensityMarker, solidFill, solidStroke }
      };
    
      //Apply the dotDensitySymbol to the CIMDotDenstityRenderer's DotDensitySymbol property.
      dotDensityRndr.DotDensitySymbol = dotDensitySymbol.MakeSymbolReference();
    
      //Apply the renderer to the polygon Feature Layer.
        featureLayer.SetRenderer(dotDensityRndr);
      });
    }
    Heat map renderer
    /// <summary>
    /// Renders a point feature layer using a continuous color gradient to represent density of points.
    /// ![Heat map renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/heat-map.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the U.S. Cities feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. Cities");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the U.S. Cities feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //defining a heatmap renderer that uses values from Population field as the weights
      HeatMapRendererDefinition heatMapDef = new HeatMapRendererDefinition()
      {
        Radius = 20,
        WeightField = "NumericField",
        ColorRamp = colorRamp,
        RendereringQuality = 8,
        UpperLabel = "High Density",
        LowerLabel = "Low Density"
      };
      await QueuedTask.Run(() =>
      {
        CIMHeatMapRenderer heatMapRndr = (CIMHeatMapRenderer)featureLayer.CreateRenderer(heatMapDef);
        featureLayer.SetRenderer(heatMapRndr);
      });
    }
    Proportional symbols renderer.
    /// <summary>
    /// Renders a feature layer using proportional symbols to draw quantities.
    /// ![Proportional Symbols renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/proportional-renderer.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Gets the first numeric field of the feature layer
      var firstNumericFieldOfFeatureLayer = "NumericFieldInLayer";
      //Gets the min and max value of the field
      var sizes = await GetFieldMinMaxAsync(featureLayer, firstNumericFieldOfFeatureLayer);
      ProportionalRendererDefinition prDef = new ProportionalRendererDefinition()
      {
        Field = firstNumericFieldOfFeatureLayer,
        MinimumSymbolSize = 4,
        MaximumSymbolSize = 50,
        LowerSizeStop = Convert.ToDouble(sizes.Item1),
        UpperSizeStop = Convert.ToDouble(sizes.Item2)
      };
      await QueuedTask.Run(() =>
      {
        CIMProportionalRenderer propRndr = (CIMProportionalRenderer)featureLayer.CreateRenderer(prDef);
        featureLayer.SetRenderer(propRndr);
      });
    }
    Simple Renderer for a Polygon feature layer.
    /// <summary>
    /// Renders a Polygon feature layer using a single symbol.
    /// ![Simple Renderer for Polygon features](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/simple-polygon.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Creating a polygon with a red fill and blue outline.
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
            ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
      CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
            ColorFactory.Instance.CreateRGBColor(255, 190, 190), SimpleFillStyle.Solid, outline);
      await QueuedTask.Run(() =>
      {
        //Get the layer's current renderer
        CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
        //Update the symbol of the current simple renderer
        renderer.Symbol = fillWithOutline.MakeSymbolReference();
    
        //Update the feature layer renderer
        featureLayer.SetRenderer(renderer);
      });
    }
    Simple Renderer for a Point feature layer.
    /// <summary>
    /// Renders a Point feature layer using a single symbol.
    /// ![Simple Renderer for Point features](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/simple-point.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPoint);
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with a point feature layer", "Data missing");
      }
      //Create a circle marker
      var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 8, SimpleMarkerStyle.Circle);
    
      await QueuedTask.Run(() =>
      {
        //Get the layer's current renderer
        CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
        //Update the symbol of the current simple renderer
        renderer.Symbol = pointSymbol.MakeSymbolReference();
    
        //Update the feature layer renderer
        featureLayer.SetRenderer(renderer);
      });
    }
    Simple Renderer for a Line feature layer.
    /// <summary>
    /// Renders a Line feature layer using a single symbol.
    /// ![Simple Renderer for Line features](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/simple-line.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Create a circle marker
      var lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 2, SimpleLineStyle.DashDotDot);
    
      await QueuedTask.Run(() =>
      {
        //Get the layer's current renderer
        CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
        //Update the symbol of the current simple renderer
        renderer.Symbol = lineSymbol.MakeSymbolReference();
    
        //Update the feature layer renderer
        featureLayer.SetRenderer(renderer);
      });
    }
    Simple Renderer for a Line feature layer using a style from a StyleProjectItem.
    /// <summary>
    /// Renders a Line feature layer using a style from a StyleProjectItem.
    /// ![Simple Renderer Style item](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/simple-line-style-item.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Get all styles in the project
      var styleProjectItem2D = project.GetItems<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
    
      //Get a specific style in the project by name
      var arrowLineSymbol = styleProjectItem2D.SearchSymbols(StyleItemType.LineSymbol, "Arrow Line 2 (Mid)")[0];
      if (arrowLineSymbol == null)
      {
        return;
      }
      await QueuedTask.Run(() =>
      {
        //Get the layer's current renderer
        var renderer = featureLayer?.GetRenderer() as CIMSimpleRenderer;
    
        //Update the symbol of the current simple renderer
        renderer.Symbol = arrowLineSymbol.Symbol.MakeSymbolReference();
    
        //Update the feature layer renderer
        featureLayer.SetRenderer(renderer);
      });
    }
    Unique Value Renderer for a feature layer
    /// <summary>
    /// Renders a feature layer using unique values from one or multiple fields
    /// ![Unique Value renderer](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/unique-value.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //construct unique value renderer definition
      UniqueValueRendererDefinition uvr = new
               UniqueValueRendererDefinition()
      {
        //Refer to the function below to get a display field of the feature layer
        ValueFields = new List<string> { await GetDisplayFieldAsync(featureLayer) }, //multiple fields in the array if needed.
        ColorRamp = colorRamp, //Specify color ramp
      };
    
      //Creates a "Renderer"
      await QueuedTask.Run(() =>
      {
        var cimRenderer = featureLayer.CreateRenderer(uvr);
    
        //Sets the renderer to the feature layer
        featureLayer.SetRenderer(cimRenderer);
      });
    
      //Function to get the display field of a feature layer
      static Task<string> GetDisplayFieldAsync(FeatureLayer featureLayer)
      {
        return QueuedTask.Run(() =>
        {
          // get the CIM definition from the layer
          var cimFeatureDefinition = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer;
          // get the view of the source table underlying the layer
          var cimDisplayTable = cimFeatureDefinition.FeatureTable;
          // this field is used as the 'label' to represent the row
          return cimDisplayTable.DisplayField;
        });
      }
    }
    Setting a unique value renderer for latest observations
    {
      await QueuedTask.Run(() =>
      {
        var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer";
        var uri = new Uri(url, UriKind.Absolute);
    
        var createParams = new FeatureLayerCreationParams(uri)
        {
          IsVisible = false
        };
        streamLayer = LayerFactory.Instance.CreateLayer<StreamLayer>(
                            createParams, map);
        //Define the unique values by hand
        var uvr = new CIMUniqueValueRenderer()
        {
          Fields = new string[] { "ACTYPE" },
          UseDefaultSymbol = true,
          DefaultLabel = "Others",
          DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(
                      CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
        };
    
        var classes = new List<CIMUniqueValueClass>
        {
          //add in classes - one for ACTYPE of 727, one for DC 9
          new CIMUniqueValueClass()
          {
            Values = new CIMUniqueValue[] {
                    new CIMUniqueValue() { FieldValues = new string[] { "B727" } } },
            Visible = true,
            Label = "Boeing 727",
            Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                      ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
          },
          new CIMUniqueValueClass()
          {
            Values = new CIMUniqueValue[] {
                    new CIMUniqueValue() { FieldValues = new string[] { "DC9" } } },
            Visible = true,
            Label = "DC 9",
            Symbol = SymbolFactory.Instance.ConstructPointSymbol(
                      ColorFactory.Instance.GreenRGB, 10, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
          }
        };
        //add the classes to a group
        var groups = new List<CIMUniqueValueGroup>()
      {
        new CIMUniqueValueGroup() {
           Classes = classes.ToArray()
        }
      };
        //add the groups to the renderer
        uvr.Groups = groups.ToArray();
        //Apply the renderer (for current observations)
        streamLayer.SetRenderer(uvr);
        streamLayer.SetVisibility(true);//turn on the layer
      });
    }
    Defining a unique value renderer definition
    {
      await QueuedTask.Run(() =>
      {
        streamLayer = null;
        //https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer
    
        var uvrDef = new UniqueValueRendererDefinition()
        {
          ValueFields = new List<string> { "ACTYPE" },
          SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol(
            ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon)
              .MakeSymbolReference(),
          ValuesLimit = 5
        };
        //Note: CreateRenderer can only create value classes based on
        //the current events it has received
        streamLayer.SetRenderer(streamLayer.CreateRenderer(uvrDef));
      });
    }
    Setting a unique value renderer for latest observations 2
    {
      await QueuedTask.Run(() =>
      {
        //Define the classes by hand to avoid using CreateRenderer(...)
        CIMUniqueValueClass uvcB727 = new CIMUniqueValueClass()
        {
          Values = new CIMUniqueValue[] { new CIMUniqueValue() { FieldValues = new string[] { "B727" } } },
          Visible = true,
          Label = "Boeing 727",
          Symbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
        };
    
        CIMUniqueValueClass uvcD9 = new CIMUniqueValueClass()
        {
          Values = new CIMUniqueValue[] { new CIMUniqueValue() { FieldValues = new string[] { "DC9" } } },
          Visible = true,
          Label = "DC 9",
          Symbol = SymbolFactory.Instance.ConstructPointSymbol(CIMColor.CreateRGBColor(0, 255, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
        };
        //Assign the classes to a group
        CIMUniqueValueGroup uvGrp = new CIMUniqueValueGroup()
        {
          Classes = new CIMUniqueValueClass[] { uvcB727, uvcD9 }
        };
        //assign the group to the renderer
        var UVrndr = new CIMUniqueValueRenderer()
        {
          Fields = new string[] { "ACTYPE" },
          Groups = new CIMUniqueValueGroup[] { uvGrp },
          UseDefaultSymbol = true,
          DefaultLabel = "Others",
          DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(
            CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference()
        };
        //set the renderer. Depending on the current events received, the
        //layer may or may not have events for each of the specified
        //unique value classes
        streamLayer.SetRenderer(UVrndr);
      });
    }
    Setting a unique value renderer for previous observations
    {
      //The layer must be track aware and spatial
      if (streamLayer.TrackType != TrackType.Spatial)
      {
        // not track aware and spatial
      }
      await QueuedTask.Run(() =>
      {
        //Define unique value classes same as we do for current observations
        //or use "CreateRenderer(...)" to assign them automatically
        CIMUniqueValueClass uvcB727Prev = new CIMUniqueValueClass()
        {
          Values = new CIMUniqueValue[] { new CIMUniqueValue() {
          FieldValues = new string[] { "B727" } } },
          Visible = true,
          Label = "Boeing 727",
          Symbol = SymbolFactory.Instance.ConstructPointSymbol(
          CIMColor.CreateRGBColor(255, 0, 0), 4, SimpleMarkerStyle.Hexagon)
          .MakeSymbolReference()
        };
    
        CIMUniqueValueClass uvcD9Prev = new CIMUniqueValueClass()
        {
          Values = new CIMUniqueValue[] { new CIMUniqueValue() {
          FieldValues = new string[] { "DC9" } } },
          Visible = true,
          Label = "DC 9",
          Symbol = SymbolFactory.Instance.ConstructPointSymbol(
            CIMColor.CreateRGBColor(0, 255, 0), 4, SimpleMarkerStyle.Hexagon)
            .MakeSymbolReference()
        };
    
        CIMUniqueValueGroup uvGrpPrev = new CIMUniqueValueGroup()
        {
          Classes = new CIMUniqueValueClass[] { uvcB727Prev, uvcD9Prev }
        };
    
        var UVrndr = new CIMUniqueValueRenderer()
        {
          Fields = new string[] { "ACTYPE" },
          Groups = new CIMUniqueValueGroup[] { uvGrpPrev },
          UseDefaultSymbol = true,
          DefaultLabel = "Others",
          DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol(
            CIMColor.CreateRGBColor(185, 185, 185), 4, SimpleMarkerStyle.Hexagon)
            .MakeSymbolReference()
        };
    
        streamLayer.SetRenderer(UVrndr, FeatureRendererTarget.PreviousObservations);
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also