require(["esri/renderers/SimpleRenderer"], function(SimpleRenderer) { /* code goes here */ });
esri/renderer/Renderer |_esri/renderer/SimpleRenderer
Name | Summary |
---|---|
new SimpleRenderer(defaultSymbol) | Creates a new SimpleRenderer object with a Symbol parameter |
new SimpleRenderer(json) | Creates a new Simple Renderer. |
Name | Type | Summary |
---|---|---|
colorInfo | Object | An object defining a color ramp used to render the layer. |
defaultSymbol | Symbol | Default symbol used when a value or break cannot be matched |
description | String | Description for the renderer |
label | String | Label for the renderer |
proportionalSymbolInfo | Object | Defines the proportional symbol rendering where feature size is proportional to data value. |
rotationInfo | Object | Defines how marker symbols are rotated. |
symbol | Symbol | The symbol for the renderer |
Name | Type | Summary |
---|---|---|
getColor(graphic) | Color | Gets the color for the Graphic. |
getRotationAngle(graphic) | Number | Returns the angle of rotation (in degrees) for the graphic calculated using rotationInfo. |
getSize(graphic) | Number | Return the symbol size (in pixels) for the graphic, calculated using proportionalSymbolInfo . |
getSymbol(graphic) | Symbol | Gets the symbol for the Graphic |
setColorInfo(info) | Renderer | Sets the colorInfo property. |
setProportionalSymbolInfo(info) | Renderer | Modify proportional symbol info for the renderer. |
setRotationInfo(info) | Renderer | Modifies rotation info for the renderer. |
toJson() | Object | Converts object to its ArcGIS Server JSON representation. |
<Symbol> defaultSymbol | Required | Symbol to use for the renderer. |
<Object> json | Required | JSON object representing the SimpleRenderer. |
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); ... });
value
and color
. value
a value in data range. color
is the color used to render the value. At least two stops are required.renderer.setColorInfo({ field: "M086_07", minDataValue: 0, maxDataValue: 100, colors: [ new Color([255, 255, 255]), new Color([127, 127, 0]) ] });
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:
If the data value represents a non-distance quantity (e.g.: traffic count, census data) then This property is required. |
valueRepresentation | String | Specifies what the data value measures if it represents a real world distance. The following values are supported:
This property is required if |
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. |
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] } });
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:
This property is optional. The default value is "geographic" |
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)
<Graphic> graphic | Required | Graphic to get color from. |
<Graphic> graphic | Required | An input graphic for which you want to get the angle of rotation. |
proportionalSymbolInfo
. (Added at v3.7)<Graphic> graphic | Required | The graphic for which you want to calculate the symbol size. |
<Graphic> graphic | Required | Graphic to symbolize. Used when creating a custom renderer. |
colorInfo
property. (Added at v3.8)<Object> info | Required | An info object that defines the color. It has the same properties as colorInfo . |
info
object has the same properties as proportionalSymbolInfo
.
For changes to take effect call the GraphicsLayer redraw
method after calling this method.
<Object> info | Required | An info object that defines the proportional symbol. The info argument has the same properties as proportionalSymbolInfo . |
rotationInfo
.
For the changes to take effect, you need to call GraphicsLayer.redraw
after calling this method. (Added at v3.7)
<Object> info | Required | An object with the same properties as rotationInfo . |