Generate data-driven visualization of unique values

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample demonstrates how to generate a data-driven visualization with unique values based on an attribute field containing categorical (or nominal) data.

This is accomplished with the createRenderer() in the type renderer creator helper object. All that is required for generating a renderer is a Feature Layer and a field name.

The createRenderer() method returns a set of symbols best suited to the given basemap. Notice that as you change the basemap using the BasemapGallery widget, the fill and outline of the symbols slightly change to a lighter or darker theme to be more visually appealing when contrasted with the basemap color.

var layer = new FeatureLayer({
  url: ""

var typeParams = {
  layer: layer,
  basemap: map.basemap,
  field: "DOM_CROP_ACRES",
  legendOptions: {
    title: "Dominant crop in harvested acres by county (2007)"

  .then(function(response) {

    // set the renderer to the layer and add it to the map

    layer.renderer = response.renderer;
  .otherwise(function(err) {
    console.error("there was an error: ", err);

A word of caution

Keep in mind that generating renderers should be avoided in most applications because of the performance cost affecting the end user. As stated in the Visualization overview: Smart mapping API guide topic, the Smart Mapping APIs were designed for two types of applications: data exploration apps and visualization authoring apps similar to ArcGIS Online. In all other cases, renderers should be saved to the layer or manually created using any of the renderer classes.

Additional visualization samples and resources

Sample search results


There were no match results from your search criteria.