Is it possible to generate a ClassBreaksDefinition from an Array instead of an attribute from a Featureclass ???

790
7
03-01-2017 02:53 AM
ChristianPagel1
New Contributor

          var classDef = new ClassBreaksDefinition();
<<<          classDef.classificationField = app.currentAttribute; >>>

<<<         assign an Array here  instead of the line before >>>
    //Known values: natural-breaks | equal-interval | quantile | standard-deviation | geometrical-interval
          classDef.classificationMethod = "natural-breaks";
          classDef.breakCount = 5;
          classDef.baseSymbol = app.symbol;

0 Kudos
7 Replies
FC_Basson
MVP Regular Contributor

Do you mean a symbology based on multiple values?  I think it should be possible if you do it with a weighted index approach.

0 Kudos
ChristianPagel1
New Contributor

Thanks for the hint. GenerateRendererTask requires a Featurelayer , therefor it's impossible to work with arrays.

Now I try to append one Calculation-Field to the Featurelayer to commit this as classificationField.

0 Kudos
thejuskambi
Regular Contributor

What would you do with that ClassBreaksDefinition?

Its purpose is to create renderer, which you will be then using to update the symbology of a graphicslayer or featurelayer. If there is no field with the values in the array, the symbology will not work.

If you are talking about creating class breaks, with values(min, max symbol etc) stored in an array. that might be possible. You need not use GenerateRendererTask. You can simply create a new ClassBreaksRenderer and update the infos property with the desired valid values.

0 Kudos
ChristianPagel1
New Contributor

Thank you for the answer.

Example: (app.Layer is a FeatureLayer)

//adding a new Field

   for (feature in app.Layer.graphics) {
       var attributes = app.Layer.graphics[feature].attributes;
       attributes["DIFF"]  =  <someValue>;
   }

Debugging app.Layer.graphics.attributes shows "DIFF" with the contents <someValue>

//here creating the ClassBreaksDefinition, GenerateRendererTask

//here Comes the error: unable to find classificationField

generateRenderer.execute(params, applyRenderer, errorHandler);

0 Kudos
thejuskambi
Regular Contributor

You cannot add a field into a FeatureLayer at runtime. Unless, you do it every time the FeatureLayer updates itself.

What kind of mode are you using for the FeatureLayer. If it is AUTO or ONDEMAND, you might have problems, because the content keeps getting updated when ever the map extent changes. You might have better luck with SNAPSHOT as the features are retrieved only once.

0 Kudos
ChristianPagel1
New Contributor

The Problem seemed to be simple:

Calculate the difference between two attributes from a Featureclass during runtime, generate Classbreaks from the difference-Attribute and rerender the map.

I think I have to look for other Solutions ...

0 Kudos
thejuskambi
Regular Contributor

Have you looked at the valueExpression  in the ClassBreaksRenderer. It uses the new Arcade format, which can be used to small calculation and use that as alternative for attributeField.

0 Kudos