Hide Table of Contents
esri
Map
plugins
process
toolbars
workers
Class: SimpleRenderer
[ AMD Module Require | Legacy Module Require ]

require(["esri/renderers/SimpleRenderer"], function(SimpleRenderer) { /* code goes here */ });

Description

(Added at v1.4)
A renderer that uses one symbol only. For more information about renderers, see Symbolizing graphics with renderers.

Samples

Search for samples that use this class.

Class hierarchy

esri/renderer/Renderer
|_esri/renderer/SimpleRenderer

Constructors

NameSummary
new SimpleRenderer(defaultSymbol)Creates a new SimpleRenderer object with a Symbol parameter
new SimpleRenderer(json)Creates a new Simple Renderer.

Properties

NameTypeSummary
colorInfoObjectAn object defining a color ramp used to render the layer.
defaultSymbolSymbolDefault symbol used when a value or break cannot be matched
descriptionStringDescription for the renderer
labelStringLabel for the renderer
proportionalSymbolInfoObjectDefines the proportional symbol rendering where feature size is proportional to data value.
rotationInfoObjectDefines how marker symbols are rotated.
symbolSymbolThe symbol for the renderer

Methods

NameTypeSummary
getColor(graphic)ColorGets the color for the Graphic.
getRotationAngle(graphic)NumberReturns the angle of rotation (in degrees) for the graphic calculated using rotationInfo.
getSize(graphic)NumberReturn the symbol size (in pixels) for the graphic, calculated using proportionalSymbolInfo.
getSymbol(graphic)SymbolGets the symbol for the Graphic
setColorInfo(info)RendererSets the colorInfo property.
setProportionalSymbolInfo(info)RendererModify proportional symbol info for the renderer.
setRotationInfo(info)RendererModifies rotation info for the renderer.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Constructor Details

new SimpleRenderer(defaultSymbol)

Creates a new SimpleRenderer object with a Symbol parameter.
Parameters:
<Symbol> defaultSymbol Required Symbol to use for the renderer.

new SimpleRenderer(json)

Creates a new Simple Renderer
Parameters:
<Object> json Required JSON object representing the SimpleRenderer.
Sample:
require([
  "esri/renderers/SimpleRenderer", ... 
], function(SimpleRenderer, ... ) {
  var simpleJson = {
    "type": "simple",
    "label": "",
    "description": "",
    "symbol": {
      "color": [210,105,30,191],
      "size": 6,
      "angle": 0,
      "xoffset": 0,
      "yoffset": 0,
      "type": "esriSMS",
      "style": "esriSMSCircle",
      "outline": {
        "color": [0,0,128,255],
        "width": 0,
        "type": "esriSLS",
        "style": "esriSLSSolid"
      }
    }
  }
  var rend = new SimpleRenderer(simpleJson);
  ...
});
Property Details

<Object> colorInfo

An object defining a color ramp used to render the layer. It has following properties:
  • <String> field: Name of the feature attribute field that contains the data value.
  • <String> normalizationField: Name of the feature attribute field by which the data value will be normalized.
  • <Number> minDataValue: Minimum data value.
  • <Number> maxDataValue: Maximum data value.
  • <Color[]> colors: An array of colors defining the color ramp. The first color will be used to render minimum data value, and the last color will be used to render maximum data value. At least two colors are required. If there are three or more colors, the intermediate colors will be placed proportionally between the first and the last to create a multi-color ramp.
  • <Object[]> stops: An array of objects defining the color ramp. Each object defines a stop on the color ramp and requires two properties: value and color. value a value in data range. color is the color used to render the value. At least two stops are required.
Specify either colors or stops to construct the color ramp. (Added at v3.8)
Sample:
renderer.setColorInfo({
  field: "M086_07",
  minDataValue: 0,
  maxDataValue: 100,
  colors: [
    new Color([255, 255, 255]),
    new Color([127, 127, 0])
  ]
});

<Symbol> defaultSymbol

Default symbol used when a value or break cannot be matched.

<String> description

Description for the renderer.

<String> label

Label for the renderer.

<Object> proportionalSymbolInfo

Defines the proportional symbol rendering where feature size is proportional to data value.

proportionalSymbolInfo supports the following properties

Property Type Description
field String or Function

Name of the feature attribute field that contains the data value. Or a function that returns the data value.

This property is required

valueUnit String

Unit of measurement if the data represents a real world distance quantity. Valid values are: "unknown","inches", "feet", "yards", "miles", "nautical-miles", "millimeters", "centimeters", "decimeters", "meters", "kilometers", "decimal-degrees"

If the data value represents a non-distance quantity (e.g.: traffic count, census data) then valueUnit should be set to "unknown".

This property is required.

valueRepresentation String Specifies what the data value measures if it represents a real world distance. The following values are supported:
  • radius: Data value represents the radius of a circular feature.
  • diameter: Data value represents the diameter of a circular feature.
  • area: Data value represents the area of a feature.
  • width: Data value represents the width of a line.
  • distance: Data value represents the distance from the center line (one half of the width).

This property is required if valueUnit is not equal to "unknown".

minDataValue Number Minimum data value. This property is required if valueUnit is set to "unknown".
minSize Number Symbol size (in pixels) to use for a feature when a minimum data value. This property is required if valueUnit is set to "unknown".
maxDataValue Number Maximum data value. This property is optional.
maxSize Number Maximum symbol size (in pixels). This property is optional.
normalizationField String Name of the feature attribute field used for data normalization. The data value obtained from field is divided by the value obtained from normalizationField before calculating the symbol size.

This property is optional.

legendOptions Object An object defining a color ramp used to render the layer. It has a property customValues, which is used when customized values in the legend are needed. See the sample section below for code example.

(Added at v3.7)
Sample: Proportional symbol rendering can be applied to two types of data:
  • Data that represents a distance quantity. For example:
    • If you have tree locations defined as points and an attribute field with the radius of tree canopy, you can use proportional symbols to depict the actual ground area covered by each tree.
    • You can use proportionally sized lines to depict the width of water mains.
  • Data that represents a non-distance quantity. For example:
    • Display traffic data like roads and highways as line symbols where stroke width is proportional to the traffic count.
    • Create a census map of proportional marker symbols where the area of each symbol reflects the population of the state.

In addition, regardless of the type of data described above, you can map a range of data values to a range of symbol sizes.

For point features, maker size is varied in proportion to the data value. For line features, stroke width is varied.

Data representing distance quantity:
 {
  field: "tree_canopy",
  valueUnit: "meters",
  valueRepresentation: "diameter"
 }
 //ground area covered by trees measured in square feet. 
 {
  field: "GroundArea", 
  valueUnit: "feet",
  valueRepresentation: "area"
 }

Specify minSize and maxSize to smooth out outliers.

Data representing a non-distance quantity.

 {
  field: "avg_daily_traffic",
  valueUnit: "unknown",
  minSize: 1000,
  minDataValue: 8
 }

Specify maxSize to smooth out outliers.

Map a range of data values to a range of symbol sizes:

{
 field: "avg_daily_traffic",
 valueUnit: "unknown",
 minSize: 1,
 maxSize: 10,
 minDataValue: 1000,
 maxDataValue: 100000
}
To use legendOptions:
renderer.setProportionalSymbolInfo({
  field: "POP_PER_DOC",
  minSize: 2,
  maxSize: 20,
  minDataValue: 100,
  maxDataValue: 10000,
  valueUnit: "unknown",
  legendOptions: {
    customValues: [100, 200, 300, 10000]
  }
});

<Object> rotationInfo

Defines how marker symbols are rotated. Use rotation to depict wind direction, vehicle heading etc. Specify an object with the following properties.
Property Type Description
field String or Function

Name of the feature attribute field that contains the angle of rotation. Or a function that returns the angle of rotation.

A function is useful in cases where the angle of rotation is not available in an attribute field but needs to be computed using a mathematical expression or formula. For example, you can specify a function to compute wind or current direction when the underlying data is stored as U or V vectors. View example below.

This property is required

type String

Defines the origin and direction of rotation depending on how the angle of rotation was measured. Can be one of the following:

  • geographic: rotates the symbol from the north in a clockwise direction.
  • arithmetic: rotates the symbol from the east in a counter-clockwise direction.

This property is optional. The default value is "geographic"

Examples:

Specify a field that contains the rotation values

{
 field: "WindDirection",
 type: "geographic"
}

Use a function to compute wind direction from wind vectors

{
 field: function(graphic){
  var U = graphic.attributes.U,
  V = graphic.attributes.V;

  //Oceanographic Convention
  return 360 + (180 / Math.PI) * Math.atan2(U,V);
 }
}
(Added at v3.7)

<Symbol> symbol

The symbol for the renderer.
Method Details

getColor(graphic)

Gets the color for the Graphic. (Added at v3.8)
Return value: Color
Parameters:
<Graphic> graphic Required Graphic to get color from.

getRotationAngle(graphic)

Returns the angle of rotation (in degrees) for the graphic calculated using rotationInfo. (Added at v3.7)
Return value: Number
Parameters:
<Graphic> graphic Required An input graphic for which you want to get the angle of rotation.

getSize(graphic)

Return the symbol size (in pixels) for the graphic, calculated using proportionalSymbolInfo. (Added at v3.7)
Return value: Number
Parameters:
<Graphic> graphic Required The graphic for which you want to calculate the symbol size.

getSymbol(graphic)

Gets the symbol for the Graphic.
Return value: Symbol
Parameters:
<Graphic> graphic Required Graphic to symbolize. Used when creating a custom renderer.

setColorInfo(info)

Sets the colorInfo property. (Added at v3.8)
Return value: Renderer
Parameters:
<Object> info Required An info object that defines the color. It has the same properties as colorInfo.

setProportionalSymbolInfo(info)

Modify proportional symbol info for the renderer. The info object has the same properties as proportionalSymbolInfo.

For changes to take effect call the GraphicsLayer redraw method after calling this method.

(Added at v3.7)
Return value: Renderer
Parameters:
<Object> info Required An info object that defines the proportional symbol. The info argument has the same properties as proportionalSymbolInfo.

setRotationInfo(info)

Modifies rotation info for the renderer. The info argument has the same properties as rotationInfo.

For the changes to take effect, you need to call GraphicsLayer.redraw after calling this method. (Added at v3.7)

Return value: Renderer
Parameters:
<Object> info Required An object with the same properties as rotationInfo.

toJson()

Converts object to its ArcGIS Server JSON representation. Not supported for the TemporalRenderer. (Added at v2.1)
Return value: Object