<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Labeling polygons with a function using LabelClass? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labeling-polygons-with-a-function-using-labelclass/m-p/252332#M23367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feature layer of polygons in my map (I'm using version 3.16).&amp;nbsp; I have fields in this layer that I want to use to label the polygons.&amp;nbsp; I have been able to use LabelClass and labelExpressionInfo to simply label the polygons with values from individual fields.&amp;nbsp; Now I want to take it a step further.&amp;nbsp; Is it possible to use a function to label my polygons with the result of subtracting one field’s values from another? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;For example, I have two fields named JanTemp and JanNormTemp.&amp;nbsp; One polygon has a JanTemp value of 27.9 and a JanNormTemp of 29.4.&amp;nbsp; I’m trying to symbolize and label the polygons with the departure from Norm value, which in this case would be -1.5.&amp;nbsp; I don’t want to just add a new field to the polygons and calculate the departures…&amp;nbsp; I’m trying to have this figure itself out programmatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;I was able to get the ClassBreaksRenderer to do this.&amp;nbsp; Here is the function I defined first:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;// Function for renderer&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;rendfunc = function(value)&amp;nbsp; {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var attr = value.attributes;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var start = attr[field1];&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var minus = attr[field2];&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (start-minus);&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;And then here is the line I used to create the CBR:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;// Set up renderer&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;var flyrRenderer = new CBRenderer(null, rendfunc);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;So far I have unsuccessful with my attempts at labeling the polygons in a similar fashion.&amp;nbsp; Has anyone else done this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:30:33 GMT</pubDate>
    <dc:creator>ZoeZaloudek</dc:creator>
    <dc:date>2021-12-11T12:30:33Z</dc:date>
    <item>
      <title>Labeling polygons with a function using LabelClass?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labeling-polygons-with-a-function-using-labelclass/m-p/252332#M23367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a feature layer of polygons in my map (I'm using version 3.16).&amp;nbsp; I have fields in this layer that I want to use to label the polygons.&amp;nbsp; I have been able to use LabelClass and labelExpressionInfo to simply label the polygons with values from individual fields.&amp;nbsp; Now I want to take it a step further.&amp;nbsp; Is it possible to use a function to label my polygons with the result of subtracting one field’s values from another? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;For example, I have two fields named JanTemp and JanNormTemp.&amp;nbsp; One polygon has a JanTemp value of 27.9 and a JanNormTemp of 29.4.&amp;nbsp; I’m trying to symbolize and label the polygons with the departure from Norm value, which in this case would be -1.5.&amp;nbsp; I don’t want to just add a new field to the polygons and calculate the departures…&amp;nbsp; I’m trying to have this figure itself out programmatically.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;I was able to get the ClassBreaksRenderer to do this.&amp;nbsp; Here is the function I defined first:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;// Function for renderer&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;rendfunc = function(value)&amp;nbsp; {&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var attr = value.attributes;&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var start = attr[field1];&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var minus = attr[field2];&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return (start-minus);&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;And then here is the line I used to create the CBR:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;// Set up renderer&lt;/SPAN&gt;
&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;var flyrRenderer = new CBRenderer(null, rendfunc);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;So far I have unsuccessful with my attempts at labeling the polygons in a similar fashion.&amp;nbsp; Has anyone else done this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:30:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/labeling-polygons-with-a-function-using-labelclass/m-p/252332#M23367</guid>
      <dc:creator>ZoeZaloudek</dc:creator>
      <dc:date>2021-12-11T12:30:33Z</dc:date>
    </item>
  </channel>
</rss>

