Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/workers
Class: GenerateRendererTask

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

Description

(Added at v2.6)
The GenerateRendererTask class creates a renderer based on a classification definition and optional where clause. The classification definition is used to define the base symbol and color ramp for the renderer. The output renderer can be applied to graphics layers, feature layers or dynamic layers. The GenerateRendererTask is available for map service or tables that support the generateDataClasses operation (version 10.1 or greater).

Samples

Search for samples that use this class.

Constructors

NameSummary
new GenerateRendererTask(url, options?)Creates a new GenerateRendererTask object.

Methods

NameReturn typeSummary
execute(generateRendererParameters, callback?, errback?)DeferredPerform a classification on the layer or table resource.

Events

[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.

Events

NameEvent ObjectSummary
complete
{
  renderer: <Renderer>
}
Fired when the classification operation is complete.
error
{
  error: <Error>
}
Fired when an error occurs during task execution.
Constructor Details

new GenerateRendererTask(url, options?)

Creates a new GenerateRendererTask object.
Parameters:
<String> url Required URL to a layer in a map service or table. Requires an ArcGIS Server version 10.1 or greater service that supports the generateDataClasses operation.
<Object> options Optional Optional parameters. See options list.
options properties:
<Boolean> checkValueRange Optional Prior to ArcGIS Server 10.2, map server/feature service only sample 1000 features to generate the renderer when using GenerateRenderer operation, which mean if there are more than 1000 features, it may run into the case that some feature will not be categorized into any breaks/unique values. If setting "checkValueRange" as true, it will query the service and find the minValue/maxValue of all the features and assign it to the min/max of the renderer. Starting ArcGIS Server 10.2, the limit is 100,000. (Add at v3.7)
<String> gdbVersion Optional Specify the geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater
Sample:
require([
  "esri/tasks/GenerateRendererTask", ... 
], function(GenerateRendererTask, ... ) {
  var countiesUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2";
  var generateRenderer = new GenerateRendererTask(countiesUrl);
  ...
});
Method Details

execute(generateRendererParameters, callback?, errback?)

Perform a classification on the layer or table resource. Upon successful completion of the classification operation the onComplete event is fired and the optional callback function is invoked. The result is a renderer object that can be applied to graphics layers, feature layers or dynamic layers.
Return type: Deferred
Parameters:
<GenerateRendererParameters> generateRendererParameters Required A GenerateRendererParameters object that defines the classification definition and an optional where clause.
<Function> callback Optional This function will be called when the operation is complete. The arguments passed to this function are the same as the OnComplete event.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution.
Sample:
require([
  "esri/tasks/GenerateRendererTask", "esri/tasks/GenerateRendererParameters", ... 
], function(GenerateRendererTask, GenerateRendererParameters, ... ) {
  var generateRenderer = new GenerateRendererTask( ... );
  var params = new GenerateRendererParameters();
  params.classificationDefinition = classDef;
  params.where = layerDef; 
  
  generateRenderer.execute(params, applyRenderer, errorHandler);
  ...
});
Event Details
[ On Style Events | Connect Style Event ]

complete

Fired when the classification operation is complete. Should be used in favor of onComplete. (Added at v3.5)
Event Object Properties:
<Renderer> renderer A renderer object that can be applied to a feature layer, graphics layer or dynamic layer.

error

Fired when an error occurs during task execution. (Added at v3.6)
Event Object Properties:
<Error> error Error message returned in a JavaScript error object.