{"id":44502,"date":"2018-08-15T10:14:53","date_gmt":"2018-08-15T17:14:53","guid":{"rendered":"https:\/\/www.esri.com\/about\/newsroom\/?post_type=arcuser&#038;p=44502"},"modified":"2024-04-30T15:40:11","modified_gmt":"2024-04-30T22:40:11","slug":"portable-arcade-expressions-help-create-client-side-data-driven-web-maps","status":"publish","type":"arcuser","link":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps","title":{"rendered":"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps"},"author":1031,"featured_media":0,"menu_order":0,"template":"","format":"standard","meta":{"_acf_changed":false,"sync_status":"","episode_type":"","audio_file":"","castos_file_data":"","podmotor_file_id":"","cover_image":"","cover_image_id":"","duration":"","filesize":"","filesize_raw":"","date_recorded":"","explicit":"","block":"","itunes_episode_number":"","itunes_title":"","itunes_season_number":"","itunes_episode_type":"","_links_to":"","_links_to_target":""},"categories":[10532,15202,25002],"tags":[35332,35342],"arcuser_issues":[21922],"class_list":["post-44502","arcuser","type-arcuser","status-publish","format-standard","hentry","category-arcgis-arcade","category-cartography","category-developers-corner","tag-arcgis-arcade","tag-scripting","arcuser_issues-spring-2018"],"acf":{"short_description":"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.","pdf":{"host_remotely":false,"file":"","file_url":""},"flexible_content":[{"acf_fc_layout":"pdf","file":181142},{"acf_fc_layout":"blockquote","content":"ArcGIS Arcade\u2014an expression language used to evaluate and return data values in pop-ups, labels, and data-driven visualizations securely across the ArcGIS platform\u2014gives you flexibility in the development process without requiring that you make changes to the feature layer."},{"acf_fc_layout":"content","content":"Similar in syntax and simplicity to spreadsheet formulas, Arcade is a powerful tool that lets you display and visualize information beyond what is immediately available in a dataset by visualizing and displaying new data values. These data values are calculated on the client side and can be formatted the way you want even if you don\u2019t own the layers containing the data.\r\n\r\nIf you are already familiar with developing custom web applications using the ArcGIS API for JavaScript, you may already know that you can evaluate custom values for visualizations and pop-ups on the client side using JavaScript functions. However, those functions can\u2019t be shared across apps and can\u2019t be saved to layers and portal items. Perhaps a more important point is that doing this with JavaScript would be insecure.\r\n\r\nWhat makes Arcade particularly powerful is that expressions <i>can<\/i> be persisted on feature layers, portal items, and web maps. Expressions written using Arcade in ArcGIS Pro, ArcGIS Online, ArcGIS Runtime, or even in custom web apps written with the ArcGIS API for JavaScript can be seamlessly used again and again across the ArcGIS platform.\r\n\r\nIf you\u2019ve been putting off getting started with Arcade, a few minutes reviewing the following examples will show you how Arcade can be useful for some common scenarios."},{"acf_fc_layout":"image","image":181182,"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h2>Normalization<\/h2>\r\nMost geospatial data visualizations use normalization. In normalization, one numeric attribute value is divided by another to minimize the influence of differences in the size of areas or the number of features in each area. For example, if I want to visualize the population for whom a second language is spoken at home for each census tract in the United States, I can use Arcade to perform the normalization using the following expression.\r\n\r\n<code>($feature.SECOND_LANGUAGE \/ $feature.POPULATION) * 100<\/code>\r\n\r\nArcade is especially useful for accomplishing this if I don\u2019t own the dataset. Since this expression executes on the client, no changes to the service are necessary, and all processing happens at runtime.\r\n<h2>Rounding<\/h2>\r\nNote that the previous expression didn\u2019t specify the precision of the returned value, so it may return values containing more significant digits than desired. Modifying the expression using Round, an out-of-the-box Arcade function, will round the value to the nearest tenth."},{"acf_fc_layout":"blockquote","content":"<code>Round(($feature.SECOND_LANGUAGE \/ $feature.POPULATION) *\\ 100, 1)<\/code>\r\n<code>\/\/ returns 31.8<\/code>"},{"acf_fc_layout":"image","image":181192,"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h2>Casting<\/h2>\r\nOne of the frustrations users have with some datasets is that the data isn\u2019t represented properly: numbers stored as strings, strings that aren\u2019t formatted, dates that are broken up and stored in multiple fields, and yes and no values that are stored as ones and zeros. Fortunately, Arcade has Text(), Number(), Date(), and Boolean() functions that (conveniently) let you cast field values as the desired type.\r\n\r\nIf you have values that have been stored as the incorrect type, you can cast those values as the correct value type so they can be properly visualized as shown in the examples Listing 1."},{"acf_fc_layout":"blockquote","content":"<code>Number(\u201928324\u2019)<\/code>\r\n<code>\/\/ returns 28324 as a number, not a string<\/code>\r\n\r\n<code>\/\/ e.g. for the value \u201939.99%\u2019<\/code>\r\n<code>Number($feature.PER_ASIAN, \u2018#.##%\u2019)<\/code>\r\n<code>\/\/ returns 0.3999 as a number<\/code>\r\n\r\n<code>Text(1234.55, \u2018$#,###.00\u2019)<\/code>\r\n<code>\/\/ returns \u2018$1,234.55\u2019 as a formatted string<\/code>\r\n\r\nListing 1: Casting data in Arcade"},{"acf_fc_layout":"content","content":"<h2>Logical Evaluation<\/h2>\r\nArcade contains six functions intended to simplify the syntax for logically evaluating values. While the syntax in Listing 2 is correct, it takes several lines of code to determine if a score is high or low based on a field value."},{"acf_fc_layout":"blockquote","content":"<code>var rank;<\/code>\r\n\r\n<code>if($feature.score &gt;= 50){<\/code>\r\n<code>\trank = \u201chigh\u201d;<\/code>\r\n<code>} else {<\/code>\r\n<code>\trank = \u201clow\u201d;<\/code>\r\n<code>}<\/code>\r\n<code>return rank;<\/code>\r\n\r\nListing 2: Logical evaluation without Arcade functions"},{"acf_fc_layout":"content","content":"Arcade conveniently simplifies this common workflow with the IIF() function, which reduces seven to eight lines of code down to just one. The same evaluation in Listing 2 is shown in Listing 3. Be sure to check out When(), Decode(), and the other useful logical functions in the Arcade documentation."},{"acf_fc_layout":"blockquote","content":"<code>IIF($feature.score &gt;= 50, \u201chigh\u201d, \u201clow\u201d);<\/code>\r\n\r\nListing 3: Logical evaluation using the IIF() functions in Arcade"},{"acf_fc_layout":"image","image":181202,"image_position":"center","orientation":"horizontal","hyperlink":""},{"acf_fc_layout":"content","content":"<h2>Complex Expressions<\/h2>\r\nArcade is designed to be lightweight and simple. Once you\u2019re familiar with the syntax, you can write powerful expressions in just one or two lines. However, you can also write longer, more complicated expressions in Arcade that can include custom functions and even geometry operations.\r\n\r\nA sample in version 3.23 of the ArcGIS API for JavaScript documentation called Geofence with Arcade details how to create a geofencing app using Arcade on a StreamLayer\u2019s renderer. The <i>ArcGIS Blog<\/i> website has featured posts that describe how to create predominance visualizations, time visualizations, and weather formulas using Arcade expressions. Search online for these posts by their titles to learn more about using longer Arcade expressions.\r\n\r\n\u201c<a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/creating-a-predominance-visualization-with-arcade\/\">Creating a predominance expression with Arcade<\/a>\u201d\r\n\r\n\u201c<a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/unwinding-the-clock-visualizing-time-with-arcade\/\">Unwinding the clock: Visualizing time with Arcade<\/a>\u201d\r\n\r\n\u201c<a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/thematic-point-clustering-for-data-exploration\/\">Thematic point clustering for data exploration<\/a>\u201d\r\n\r\n\u201c<a href=\"https:\/\/www.esri.com\/arcgis-blog\/products\/mapping\/mapping\/using-arcade-expressions-in-web-apps\/\">Using Arcade expressions in web apps<\/a>\u201d\r\n<h2>When Not to Use Arcade<\/h2>\r\nWhile Arcade gives you unprecedented flexibility in customizing layer styles and pop-ups, even layers owned by others, it shouldn\u2019t be used in every case even if it is permitted.\r\n\r\n<i>If you have full ownership of a layer containing the data you want to visualize in a web app and that data is already stored in a clean, acceptable way, you don\u2019t need to write Arcade expressions.<\/i> You can store values used for the data-driven visualization, pop-ups, and labels in service fields, so there is no need to write Arcade expressions for formatting or casting values.\r\n\r\nThe examples in this article use Arcade for normalizing, rounding, and casting when you don\u2019t have privileges for the dataset you want to use and need a quick way to modify field values.\r\n\r\n<i>It\u2019s also important to keep in mind that not every function included in the Arcade language should be used in all available profiles or contexts for which they can be used.<\/i> Arcade provides 32 geometry functions and, in theory, any of them could be used in any profile: visualization, labeling, or pop-ups.\r\n\r\nHowever, remember that Arcade executes on a feature-by-feature basis, so executing multiple geometry operations for each feature may not provide an optimal user experience if used in visualization and labeling profiles. It may be more appropriate to reserve more complex expressions using multiple geometric operations for the pop-up profile, because with that profile, the expression will execute only when a feature is clicked.\r\n<h2>The Future<\/h2>\r\nThe December 2017 release of Arcade (version 1.3) introduced more than two dozen geometry functions that include measurement operations, overlay operations, and topological testing functions. Many geometry functions, such as the overlay and testing functions, require more than one input geometry. In the current release of Arcade, you can manually construct geometry objects as needed within the expression, such as calculating the distance from one hard-coded point to all points in a layer.\r\n\r\nFuture releases will provide methods that allow you to access other geometries within the same layer, related tables, and features in other layers. Additional functionality will continually be added to Arcade, but you can take advantage of the out-of-the-box functions right now. You can also go outside the box by writing your own functions."}],"references":null},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps | Spring 2018 | ArcUser<\/title>\n<meta name=\"description\" content=\"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps\" \/>\n<meta property=\"og:description\" content=\"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps\" \/>\n<meta property=\"og:site_name\" content=\"Esri\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/esrigis\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T22:40:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/auspr18_arcade_card.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@Esri\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\/\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps\",\n\t            \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps\",\n\t            \"name\": \"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps | Spring 2018 | ArcUser\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#website\"\n\t            },\n\t            \"datePublished\": \"2018-08-15T17:14:53+00:00\",\n\t            \"dateModified\": \"2024-04-30T22:40:11+00:00\",\n\t            \"description\": \"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.\",\n\t            \"breadcrumb\": {\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps#breadcrumb\"\n\t            },\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"BreadcrumbList\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps#breadcrumb\",\n\t            \"itemListElement\": [\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 1,\n\t                    \"name\": \"Home\",\n\t                    \"item\": \"https:\/\/www.esri.com\/about\/newsroom\"\n\t                },\n\t                {\n\t                    \"@type\": \"ListItem\",\n\t                    \"position\": 2,\n\t                    \"name\": \"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps\"\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#website\",\n\t            \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/\",\n\t            \"name\": \"Esri\",\n\t            \"description\": \"Esri Newsroom\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\/\/www.esri.com\/about\/newsroom\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/82e5143bcdebadf8fd64d84e503ca468\",\n\t            \"name\": \"Monica Pratt\",\n\t            \"image\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/image\/\",\n\t                \"url\": \"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg\",\n\t                \"contentUrl\": \"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg\",\n\t                \"caption\": \"Monica Pratt\"\n\t            },\n\t            \"description\": \"Monica Pratt is the founding and current editor of ArcUser magazine, the executive editor of ArcNews magazine, the editor of Esri Globe and head of the Publications team at Esri. She has been writing on technology topics, specializing in GIS, for more than 30 years. Before joining Esri in 1997, she worked for newspapers and in the financial industry.\",\n\t            \"sameAs\": [\n\t                \"https:\/\/x.com\/ArcUser\"\n\t            ],\n\t            \"url\": \"\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps | Spring 2018 | ArcUser","description":"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps","og_locale":"en_US","og_type":"article","og_title":"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps","og_description":"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.","og_url":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps","og_site_name":"Esri","article_publisher":"https:\/\/www.facebook.com\/esrigis\/","article_modified_time":"2024-04-30T22:40:11+00:00","og_image":[{"url":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/auspr18_arcade_card.jpg","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@Esri","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps","url":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps","name":"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps | Spring 2018 | ArcUser","isPartOf":{"@id":"https:\/\/www.esri.com\/about\/newsroom\/#website"},"datePublished":"2018-08-15T17:14:53+00:00","dateModified":"2024-04-30T22:40:11+00:00","description":"Make your maps do so much more with ArcGIS Arcade, a cross-platform expression language.","breadcrumb":{"@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.esri.com\/about\/newsroom\/arcuser\/portable-arcade-expressions-help-create-client-side-data-driven-web-maps#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.esri.com\/about\/newsroom"},{"@type":"ListItem","position":2,"name":"Portable Arcade Expressions Help Create Client-Side, Data-Driven Web Maps"}]},{"@type":"WebSite","@id":"https:\/\/www.esri.com\/about\/newsroom\/#website","url":"https:\/\/www.esri.com\/about\/newsroom\/","name":"Esri","description":"Esri Newsroom","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.esri.com\/about\/newsroom\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/82e5143bcdebadf8fd64d84e503ca468","name":"Monica Pratt","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.esri.com\/about\/newsroom\/#\/schema\/person\/image\/","url":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg","contentUrl":"https:\/\/www.esri.com\/about\/newsroom\/app\/uploads\/2018\/08\/MonicaMug_agol2.jpg","caption":"Monica Pratt"},"description":"Monica Pratt is the founding and current editor of ArcUser magazine, the executive editor of ArcNews magazine, the editor of Esri Globe and head of the Publications team at Esri. She has been writing on technology topics, specializing in GIS, for more than 30 years. Before joining Esri in 1997, she worked for newspapers and in the financial industry.","sameAs":["https:\/\/x.com\/ArcUser"],"url":""}]}},"sort_order":"12","_links":{"self":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser\/44502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser"}],"about":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/types\/arcuser"}],"author":[{"embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/users\/1031"}],"version-history":[{"count":0,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser\/44502\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/media?parent=44502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/categories?post=44502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/tags?post=44502"},{"taxonomy":"arcuser_issues","embeddable":true,"href":"https:\/\/www.esri.com\/about\/newsroom\/wp-json\/wp\/v2\/arcuser_issues?post=44502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}