<?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 Re: ArcGIS JavaScript Components - Update chart when selecting a feature. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409188#M84307</link>
    <description>&lt;P&gt;Thank you for your reply! That is very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been running into issues while attempting to utilize the proof a concept provided. Is it possible to utilize the " view.on('click " while referencing an&amp;nbsp;&amp;lt;arcgis-map&amp;gt;&lt;SPAN&gt;&amp;nbsp;component?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on('click', function (event) {
      var screenPoint = event.screenPoint;

      view.hitTest(screenPoint).then(getFeatures);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are&amp;nbsp;&amp;lt;arcgis-map&amp;gt;&lt;SPAN&gt;&amp;nbsp;component 'events' required instead? The following code sample provides a reference to what I am describing. However, the code sample does not work in it's current form.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const map = document.querySelector("arcgis-map");

map.addEventListener("arcgisViewClick", (event) =&amp;gt; {
  const { view } = event.target;
  var screenPoint = event.screenPoint;
  view.hitTest(screenPoint).then(getFeatures);
});

function getFeatures(response) {
  // get the selected feature's ObjectId from the hitTest
  const selectedFeatureOID = response.results[0].graphic.attributes['ObjectId'];
  // set the selected feature's OID to the Charts component's selectionData
  pieChartElement.selectionData = { selectionOIDs: [selectedFeatureOID] };
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2024 19:38:57 GMT</pubDate>
    <dc:creator>dgreenin</dc:creator>
    <dc:date>2024-04-12T19:38:57Z</dc:date>
    <item>
      <title>ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1407991#M84276</link>
      <description>&lt;P&gt;Good Morning,&lt;/P&gt;&lt;P&gt;I am currently working with ArcGIS JavaScript Components (beta).&amp;nbsp;&lt;/P&gt;&lt;P&gt;The current documentation shows how to highlight map features based on selections made within a chart component (ie. pie chart).&lt;/P&gt;&lt;P&gt;However, I would like to update the chart component (ie. pie chart) based on the selection of a feature within a feature layer on the map.&lt;/P&gt;&lt;P&gt;'Example: Feature layer contains county boundary polygons for a state and associated demographics for each county. Current pie chart shows demographics for entire feature layer (ie. state). Desired outcome would be to select an individuial county and update the pie chart to reflect demographics of that county only.'&lt;/P&gt;&lt;P&gt;There are currently no tutorials on how to do this. Is this possible using the current Components API (beta)?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 18:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1407991#M84276</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-10T18:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1408885#M84299</link>
      <description>&lt;P&gt;Hi dgreenin, thank you for reaching out about this.&lt;/P&gt;&lt;P&gt;Currently, you can make a selection on the feature layer view and pass those selected features into the chart component.&lt;/P&gt;&lt;P&gt;This will not generate a new chart, but it will highlight the selected features. From there, you can use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&amp;lt;arcgis-charts-action-bar&amp;gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;component's built-in 'Filter by selection' feature to help you narrow down your chart's visualization.&lt;/P&gt;&lt;P&gt;Here's a quick proof of concept for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on('click', function (event) {
      var screenPoint = event.screenPoint;

      view.hitTest(screenPoint).then(getFeatures);
    });

    function getFeatures(response) {
      // get the selected feature's ObjectId from the hitTest
      const selectedFeatureOID = response.results[0].graphic.attributes['ObjectId'];
      
      // set the selected feature's OID to the Charts component's selectionData
      scatterplotElement.selectionData = { selectionOIDs: [selectedFeatureOID] };
    }

// Use the action bar to filter by selection...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We will work on including this workflow in the tutorial, as it's an important way for users to visualize the data between the map and the chart.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 04:36:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1408885#M84299</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-04-12T04:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409188#M84307</link>
      <description>&lt;P&gt;Thank you for your reply! That is very helpful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been running into issues while attempting to utilize the proof a concept provided. Is it possible to utilize the " view.on('click " while referencing an&amp;nbsp;&amp;lt;arcgis-map&amp;gt;&lt;SPAN&gt;&amp;nbsp;component?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.on('click', function (event) {
      var screenPoint = event.screenPoint;

      view.hitTest(screenPoint).then(getFeatures);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are&amp;nbsp;&amp;lt;arcgis-map&amp;gt;&lt;SPAN&gt;&amp;nbsp;component 'events' required instead? The following code sample provides a reference to what I am describing. However, the code sample does not work in it's current form.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const map = document.querySelector("arcgis-map");

map.addEventListener("arcgisViewClick", (event) =&amp;gt; {
  const { view } = event.target;
  var screenPoint = event.screenPoint;
  view.hitTest(screenPoint).then(getFeatures);
});

function getFeatures(response) {
  // get the selected feature's ObjectId from the hitTest
  const selectedFeatureOID = response.results[0].graphic.attributes['ObjectId'];
  // set the selected feature's OID to the Charts component's selectionData
  pieChartElement.selectionData = { selectionOIDs: [selectedFeatureOID] };
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 19:38:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409188#M84307</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-12T19:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409194#M84308</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You are correct! You can grab the view from the&amp;nbsp;&lt;/SPAN&gt;event.target&lt;SPAN&gt;&amp;nbsp;of the&amp;nbsp;&lt;/SPAN&gt;&amp;lt;arcgis-map&amp;gt;&lt;SPAN&gt;&amp;nbsp;component. With the 'arcgisViewReadyChange' event listener added, the view will be ready to use by the time you define your click function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;document.querySelector('arcgis-map').addEventListener('arcgisViewReadyChange', (event) =&amp;gt; {
  
  const { map, view } = event.target;
     
  // use the view.on('click') here...
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 19:48:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409194#M84308</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-04-12T19:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409212#M84309</link>
      <description>&lt;P&gt;Thank you again for the fast reply!&lt;/P&gt;&lt;P&gt;I have attempted to utilize the provided code sample (compiled) without success. While selecting a feature within the referenced map component, the "Filter By Selection" option does not light up (is not selectable) within the associated chart's "Action Bar".&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;document.querySelector('arcgis-map').addEventListener('arcgisViewReadyChange', (event) =&amp;gt; {
  
  const { map, view } = event.target;
     
  view.on('click', function (event) {
    var screenPoint = event.screenPoint;

    view.hitTest(screenPoint).then(getFeatures);
  });

  function getFeatures(response) {
    // get the selected feature's ObjectId from the hitTest
    const selectedFeatureOID = response.results[0].graphic.attributes['ObjectId'];
    
    // set the selected feature's OID to the Charts component's selectionData
    scatterplotElement.selectionData = { selectionOIDs: [selectedFeatureOID] };
  }

// Use the action bar to filter by selection...
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For reference, my current web application setup (map, layer &amp;amp; chart) is based on the following ArcGIS Maps SDK for JavaScript Components (beta) Tutorial.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tutorial: 'Charts components with Map components'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Tutorial URL: &lt;A href="https://developers.arcgis.com/javascript/latest/tutorials/charts-components-with-map-components/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/tutorials/charts-components-with-map-components/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;*Refer to the sections 'Add styles', 'Add components' and 'Load the feature layer item'.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 20:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409212#M84309</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-12T20:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409223#M84310</link>
      <description>&lt;P&gt;You can manually set the 'disable-filter-by-selection' to false in your action bar.&lt;/P&gt;&lt;P&gt;Your HTML would look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;arcgis-charts-scatter-plot id="scatterplot"&amp;gt;
  &amp;lt;arcgis-charts-action-bar slot="action-bar" disable-filter-by-selection="false"&amp;gt;&amp;lt;/arcgis-charts-action-bar&amp;gt;
&amp;lt;/arcgis-charts-scatter-plot&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To further customize the actions/controls of the action-bar component, you can adjust the properties to suit the needs of your application (enabling/disabling certain actions): &lt;A href="https://developers.arcgis.com/javascript/latest/components/storybook/?path=/docs/charts-components_component-reference-action-bar--docs" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/components/storybook/?path=/docs/charts-components_component-reference-action-bar--docs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 20:50:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1409223#M84310</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-04-12T20:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410281#M84347</link>
      <description>&lt;P&gt;I am currently encountering an error when selecting 'Filter by selection' in the action bar (see the attached screenshot).&lt;/P&gt;&lt;P&gt;Through the use of 'console.log' I see that the objectid is returned correctly when the feature is selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const selectedFeatureOID = response.results[0].graphic.attributes['OBJECTID'];
console.log(selectedFeatureOID)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it appears as though the following line of code is not registering correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;scatterplotElement.selectionData = { selectionOIDs: [selectedFeatureOID] }; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 15:11:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410281#M84347</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-16T15:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410385#M84349</link>
      <description>&lt;P&gt;Hi dgreenin,&lt;/P&gt;&lt;P&gt;I have put together a CodePen with the working scenario:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://codepen.io/jchenAtlas/pen/poBOgGE" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" target="_blank" rel="noopener"&gt;https://codepen.io/jchenAtlas/pen/poBOgGE&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I changed a couple of things to follow some patterns for Map Components (using the "arcgisViewClick" event listener instead of the view onClick).&lt;/P&gt;&lt;P&gt;Feel free to replace the layer ID and name on lines 40 and 59, and let me know if this sample works with your own layer as well.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 16:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410385#M84349</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-04-16T16:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410953#M84361</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/48087" target="_self"&gt;&lt;SPAN class=""&gt;HaoyanChen,&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This works great for a bar-chart and scatter-plot! Thank you for providing the sample code in codepen. It is very helfpul to see the code compiled in one place (Sample code referenced below).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HaoyanChen Sample Code - 'Sync up selection with Map and Chart':&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/jchenAtlas/pen/poBOgGE" target="_blank" rel="noopener"&gt;https://codepen.io/jchenAtlas/pen/poBOgGE&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, this sample code does not work for a pie-chart. The 'Filter by selection' option, when selected in the action-bar for a pie-chart, will result in an error as previously posted (Screenshot attached for reference).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following sample code&amp;nbsp;'Query statistics client-side' represents the functionality I am pursuing. The intent would be to use 'query by selection' (as we have been working on) in place of 'query by extent' to update a pie-chart.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ArcGIS JavaScript Sample Code - 'Query statistics client-side':&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=featurelayerview-query-stats" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=featurelayerview-query-stats&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 20:48:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1410953#M84361</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-17T20:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1411843#M84373</link>
      <description>&lt;P&gt;Hi dgreenin,&lt;/P&gt;&lt;P&gt;This might be caused by the specific layer that is being used. I tested with the same data from the CodePen with a pie chart and the "Filter by selection" is working as expected.&lt;BR /&gt;&lt;BR /&gt;Pie chart selection:&amp;nbsp;&lt;A href="https://codepen.io/jchenAtlas/pen/poBOgGE" target="_blank"&gt;https://codepen.io/jchenAtlas/pen/poBOgGE&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please send me a direct message and we can dig deeper if it's a layer specific issue or maybe a field specific issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 19:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1411843#M84373</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-04-18T19:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1415007#M84411</link>
      <description>&lt;P&gt;Good Afternoon&amp;nbsp;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/48087" target="_self"&gt;&lt;SPAN class=""&gt;HaoyanChen&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I have continued testing to achieve the intial functionality I was in pursuit of.&lt;/P&gt;&lt;P&gt;Here is a detailed description of the problem/solution:&lt;/P&gt;&lt;P&gt;When initially configuring the format of pie charts within a web map, there are two choices for creating slices, 'Category' and 'Fields'.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;'Category' represents one field from a layer with each slice representing different unique value within the field.&lt;/LI&gt;&lt;LI&gt;'Numeric' represents one or more numeric fields in a layer with each slice displaying the sum total of each individual numeric field.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The effort then becomes, how do you represent the 'Numeric' slices for a single feature within a layer rather than the sum of features for the entire layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Through intitial testing, the selection functionality we have worked on didn't quite achieve this functionality.&lt;/P&gt;&lt;P&gt;My current solution is to introduce a definition query tied to the selection of an individual feature.&lt;/P&gt;&lt;P&gt;I have utilized your coding sample as a base for showing this functionality. I could use some assistance on clearing the definition query when selecting blank portion of the map.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;ArcGIS Maps SDK for JavaScript Tutorials: Display a map using arcgis/map-components&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
        html,
        body {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }

        #pie-chart {
            position: absolute;
            bottom: 30px;
            left: 30px;
            height: 40%;
            width: 50%;
        }
    &amp;lt;/style&amp;gt;

    &amp;lt;!-- Load Map Components from CDN--&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.29/@arcgis/core/assets/esri/themes/light/main.css"&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/2.5.1/calcite.css" /&amp;gt;

    &amp;lt;script src="https://js.arcgis.com/4.29/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/calcite-components/2.5.1/calcite.esm.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/map-components/4.29/arcgis-map-components.esm.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/charts-components/4.29/arcgis-charts-components.esm.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

    &amp;lt;arcgis-map item-id="9a043ed7a9ae42658459e4a5df9427e5"&amp;gt;&amp;lt;/arcgis-map&amp;gt;
    &amp;lt;arcgis-charts-pie-chart id="pie-chart"&amp;gt;
        &amp;lt;arcgis-charts-action-bar slot="action-bar" disable-filter-by-selection="false"&amp;gt;&amp;lt;/arcgis-charts-action-bar&amp;gt;
    &amp;lt;/arcgis-charts-pie-chart&amp;gt;

    &amp;lt;script type="module"&amp;gt;

        const map = document.querySelector("arcgis-map");


        map.addEventListener("arcgisViewReadyChange", (event) =&amp;gt; {
            const { map, view } = event.target;
            const layer = map.layers.find((layer) =&amp;gt; layer.title === 'USA Census States');

            view.on("click", (event) =&amp;gt; {
                queryFeatures(event);
            });

            function queryFeatures(event) {

                const layerQuery = {
                    geometry: event.mapPoint,
                    // distance and units will be null if basic query selected
                    spatialRelationship: "intersects",
                    returnGeometry: true,
                    outFields: ["STATE_ABBR"]
                };
                
                layer.queryFeatures(layerQuery)
                .then((results) =&amp;gt; {

                const layerCount = results.features;
                layerCount.forEach((result) =&amp;gt; {
                    const attributes = result.attributes;
                    const state = `${attributes.STATE_ABBR}`;
                    if (state.length &amp;gt; 0) {
                    layer.definitionExpression = `STATE_ABBR = '${state}'`;
                    } else {
                    // Insert code to clear definition query
                    }
                })
                
                }).catch((error) =&amp;gt; {
                    console.log(error);
                });
            };
            const pieChartElement = document.getElementById("pie-chart");
            const pieChartConfig = layer.charts[1];
    
            pieChartElement.config = pieChartConfig;
            pieChartElement.layer = layer;
        });

    &amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 20:03:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1415007#M84411</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-04-26T20:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1475451#M84667</link>
      <description>&lt;P&gt;Hi dgreenin,&lt;/P&gt;&lt;P&gt;I have modified the provided code below, please take a look and read thru the comments and let me know if this helped to achieve your initial goal.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;In the modified code, we first check if `layerCount.length &amp;gt; 0`.&amp;nbsp;&lt;SPAN&gt;If it is, we proceed as before. If it's not (meaning we clicked on an empty part of the map), we clear the definition query by setting&amp;nbsp;`layer.definitionExpression`&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;to an empty string.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;ArcGIS Maps SDK for JavaScript Tutorials: Display a map using arcgis/map-components&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
        html,
        body {
            padding: 0;
            margin: 0;
            height: 100%;
            width: 100%;
        }

        #pie-chart {
            position: absolute;
            bottom: 30px;
            left: 30px;
            height: 40%;
            width: 50%;
        }
    &amp;lt;/style&amp;gt;

    &amp;lt;!-- Load Map Components from CDN--&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css"&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.29/@arcgis/core/assets/esri/themes/light/main.css"&amp;gt;
    &amp;lt;link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/2.5.1/calcite.css" /&amp;gt;

    &amp;lt;script src="https://js.arcgis.com/4.29/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/calcite-components/2.5.1/calcite.esm.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/map-components/4.29/arcgis-map-components.esm.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script type="module" src="https://js.arcgis.com/charts-components/4.29/arcgis-charts-components.esm.js"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

    &amp;lt;arcgis-map item-id="9a043ed7a9ae42658459e4a5df9427e5"&amp;gt;&amp;lt;/arcgis-map&amp;gt;
    &amp;lt;arcgis-charts-pie-chart id="pie-chart"&amp;gt;
        &amp;lt;arcgis-charts-action-bar slot="action-bar" disable-filter-by-selection="false"&amp;gt;&amp;lt;/arcgis-charts-action-bar&amp;gt;
    &amp;lt;/arcgis-charts-pie-chart&amp;gt;

    &amp;lt;script type="module"&amp;gt;

        const map = document.querySelector("arcgis-map");


        map.addEventListener("arcgisViewReadyChange", (event) =&amp;gt; {
            const { map, view } = event.target;
            const layer = map.layers.find((layer) =&amp;gt; layer.title === 'USA Census States');

            view.on("click", (event) =&amp;gt; {
                queryFeatures(event);
            });

            function queryFeatures(event) {

                const layerQuery = {
                    geometry: event.mapPoint,
                    spatialRelationship: "intersects",
                    returnGeometry: true,
                    outFields: ["STATE_ABBR"]
                };

                layer.queryFeatures(layerQuery)
                    .then((results) =&amp;gt; {
                        const layerCount = results.features;
                        if (layerCount.length &amp;gt; 0) {
                            layerCount.forEach((result) =&amp;gt; {
                                const attributes = result.attributes;
                                const state = `${attributes.STATE_ABBR}`;
                                if (state.length &amp;gt; 0) {
                                    layer.definitionExpression = `STATE_ABBR = '${state}'`;
                                }
                            });
                        } else {
                            // Clear definition query
                            layer.definitionExpression = '';
                        }

                    }).catch((error) =&amp;gt; {
                        console.log(error);
                    });
            };
            const pieChartElement = document.getElementById("pie-chart");
            const pieChartConfig = layer.charts[1];

            pieChartElement.config = pieChartConfig;
            pieChartElement.layer = layer;
        });

    &amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 15:00:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1475451#M84667</guid>
      <dc:creator>HaoyanChen</dc:creator>
      <dc:date>2024-05-20T15:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS JavaScript Components - Update chart when selecting a feature.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1480427#M84744</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/48087"&gt;@HaoyanChen&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;That works perfectly! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 17:59:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-javascript-components-update-chart-when/m-p/1480427#M84744</guid>
      <dc:creator>dgreenin</dc:creator>
      <dc:date>2024-05-29T17:59:15Z</dc:date>
    </item>
  </channel>
</rss>

