Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to create a ClassBreakRenderer to represent integer values. The symbols I am using are defined as PictureMarkerSymbols with JSON and they are just a filled blue circle with different sizes that were created with ArcMap 10.1 and published into ArcGIS Server. This is just to introduce the thing.

The problem is that in all the examples I see on the ArcGIS Javascript API about Rendering, the examples do always get the data from a particular column of a Feature Layer, but my data do NOT come from this data source: they come from an array of integers in client side. Just the symbol comes from the server-side, but not the integer value.

Is there any way of "tricking" the constructor of ClassBreakRenderer in order to accept an array (or collection, dictionary, set, whatever) of integers to be classified in symbols? There should be "life" a part of Feature Layers, isn't it?

Thanks for your help!


EDIT

The thing is that my data source is an array of integers like this:

var myArray = [15, 37, 47, 12, 125, 87, 36, 66, 10, 4, 18, 19, 23]

AND NOT:

var featureLayer = new esri.layers.FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3", {
          mode: esri.layers.FeatureLayer.MODE_SNAPSHOT,
          outFields: ["*"],

And in principle, the ClassBreakRenderer receives a column of that Feature Layer as:

var renderer = new esri.renderer.ClassBreaksRenderer(symbol, "POP07_SQMI");

But I do NOT have that column "POP07_SQMI" I have an array called "myArray" and my question is that if it is possible to use the array instead of the column name that I don't have. Because world should not be limited to the existence of feature layers to retrieve data from them.... :S

share|improve this question
    
Your renderer has to reference an attribute field from your feature layer. You can define the breaks however you like, but the renderer uses the value from some field for each feature out how to symbolize it. Are you sure you want a class breaks renderer and not a unique value renderer? –  Derek Swingley Dec 5 '12 at 2:02

2 Answers 2

In the newest versions of ArcGIS for JavaScript, you can use the ClassBreaksRenderer to render data coming from an array. Instead of referencing a FeatureLayer column in the call to the classBreaksRenderer like this:

var renderer = new esri.renderer.ClassBreaksRenderer(symbol, "POP07_SQMI");

reference a call to a function, like this:

var renderer = new esri.renderer.ClassBreaksRenderer(null, myFunction());

You need to have the myFunction() function return a distinct number for each key value that you input into the myFunction() as an input parameter. Basically you feed myFunction() an input parameter and return the number you want to classify that key to.

share|improve this answer

Create your own class breaks renderer, specify your breaks using addBreak, then apply your renderer to the feature layer using setRenderer. You'll probably want to create your feature layer with visible: false then call show() once you apply the renderer.

share|improve this answer
    
But it turns out that I do NOT have a Feature Layer as a source for data. I have sth like: var myArray = [1, 2, 3, 4, 5 ...]. Did I misunderstood you? –  iamgin Dec 4 '12 at 23:11
    
I think we misunderstood each other. I'm not clear on what you want to do. Can you edit your question and clarify what you're doing? What is the data source? –  Derek Swingley Dec 4 '12 at 23:17
    
Hope you find it clearer now. Thanks. –  iamgin Dec 4 '12 at 23:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.