<?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 Difficulty recreating heatmap renderer with time slider in ArcGIS JS API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/difficulty-recreating-heatmap-renderer-with-time/m-p/1012375#M71195</link>
    <description>&lt;P&gt;&lt;FONT size="5"&gt;The Goal&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I am trying to recreate what I created in ArcGIS online using the ArcGIS JS API.&amp;nbsp; I have this webmap which uses a heatmap to visualize COVID numbers by country, with a time slider, as this is a time aware layer:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.arcgis.com/home/webmap/viewer.html?webmap=3f2a6426b68247428618ce08bf5ac10b" target="_blank" rel="noopener"&gt;https://www.arcgis.com/home/webmap/viewer.html?webmap=3f2a6426b68247428618ce08bf5ac10b&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I love the distribution of colors from the low end to the high end, and how it evolves over time.&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;What I've Tried&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I am trying to code this from scratch using the api.&amp;nbsp; I'm having a hard time.&amp;nbsp; In order to get the map to show the right data according to the current timeslider timeextent, I followed the advice from&amp;nbsp;&lt;A href="https://gis.stackexchange.com/questions/372782/arcgis-js-api-time-series-with-heatmap" target="_self"&gt;this GIS stack exhange question&lt;/A&gt;&amp;nbsp;, and the layer's definitionExpression is updated with each timeslider change:&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;timeSlider.watch('timeExtent', function (value) {
		updateDefintionExpression(value);
});

function updateDefintionExpression(timeExtent) {
	const start = toDateString(timeExtent.start);
	const end = toDateString(timeExtent.end);
	covidLayer.definitionExpression = `Date &amp;gt;= DATE '${start}' AND Date &amp;lt;= DATE '${end}'`;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came up with a heatmap renderer from scratch, but it doesn't show off the low end as well as I'd like.&amp;nbsp; Here is the renderer code:&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;renderer: {
			type: 'heatmap',
			field: 'Confirmed',
			colorStops: [
				{ ratio: 0, color: 'rgba(255, 255, 255, 0)' },
				{ ratio: 0.06, color: 'rgba(255, 255, 255, 1)' },
				{ ratio: 0.15, color: 'rgba(255, 255, 0, 1)' },
				{ ratio: 0.25, color: 'rgba(255, 140, 0, 1)' },
				{ ratio: 0.55, color: 'rgba(255, 0, 0, 1)' },
			],
			minPixelIntensity: 1,
			maxPixelIntensity: 150000000,
			blurRadius: 12,
		},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see this in action here:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/poEdqEz" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/poEdqEz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I played endlessly with the stops and the pixelIntensities, and I couldn't get a good range across the low end and high end (low numbers in the data vs high numbers in the data).&lt;/P&gt;&lt;P&gt;I looked into the JSON for the arcgis webmap I initially cereated, and this is the renderer it shows:&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;renderer: {
      type: "heatmap",
      blurRadius: 10,
      colorStops: [
        {
          ratio: 0,
          color: [212, 227, 245, 0]
        },
        {
          ratio: 0.01,
          color: [212, 227, 245, 0]
        },
        // ... more color stops
        {
          ratio: 0.9175000000000001,
          color: [204, 211, 51, 255]
        },
        {
          ratio: 1,
          color: [255, 255, 0, 255]
        }
      ],
      maxPixelIntensity: 9566880,
      minPixelIntensity: 0,
      field: "Confirmed"
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using that, I get this result:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/eYdebdp" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/eYdebdp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also not quite right - the low end looks nice, but the high end looks blown out, like the heatmap is overflowing against an invisible square border.&amp;nbsp; Take a look - here is my goal:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-26 at 9.10.04 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/2890iEF3544278FB01EA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-12-26 at 9.10.04 PM.png" alt="Screen Shot 2020-12-26 at 9.10.04 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But here is what I'm getting with the JS API:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-26 at 9.10.00 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/2891iF69D11EB744DBBB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-12-26 at 9.10.00 PM.png" alt="Screen Shot 2020-12-26 at 9.10.00 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure why in my handcoded app, the heatmap looks "cut off"...if I can fix this, then the renderer from JSON will probably work just fine.&amp;nbsp; (And how to get that nice fade-out effect?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried using the smartmapping heatmap renderer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  timeSlider.watch("timeExtent", function (value) {
    updateDefintionExpression(value);

    const params = {
       layer: covidLayer,
       view,
       field: "Confirmed",
       fadeToTransparent: true,
       minRatio: 0.05
    }

    heatmapRendererCreator.createRenderer(params)
    .then(result =&amp;gt; {
       covidLayer.renderer = result.renderer
       console.log(result.renderer)
    })
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see the result here:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/VwKrqKr" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/VwKrqKr&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is also not correct.&amp;nbsp; This seems to re-evaluate the total range of values on each timeslider update, and distribute the heatmap accordingly, making each timestep look very similar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve the effect that I have in the arcgis online web map, using the JS API?&amp;nbsp; I feel I am close but struggling to see the right way.&lt;/P&gt;</description>
    <pubDate>Sun, 27 Dec 2020 05:13:18 GMT</pubDate>
    <dc:creator>SethLutske</dc:creator>
    <dc:date>2020-12-27T05:13:18Z</dc:date>
    <item>
      <title>Difficulty recreating heatmap renderer with time slider in ArcGIS JS API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/difficulty-recreating-heatmap-renderer-with-time/m-p/1012375#M71195</link>
      <description>&lt;P&gt;&lt;FONT size="5"&gt;The Goal&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I am trying to recreate what I created in ArcGIS online using the ArcGIS JS API.&amp;nbsp; I have this webmap which uses a heatmap to visualize COVID numbers by country, with a time slider, as this is a time aware layer:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.arcgis.com/home/webmap/viewer.html?webmap=3f2a6426b68247428618ce08bf5ac10b" target="_blank" rel="noopener"&gt;https://www.arcgis.com/home/webmap/viewer.html?webmap=3f2a6426b68247428618ce08bf5ac10b&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I love the distribution of colors from the low end to the high end, and how it evolves over time.&lt;/P&gt;&lt;P&gt;&lt;FONT size="5"&gt;What I've Tried&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I am trying to code this from scratch using the api.&amp;nbsp; I'm having a hard time.&amp;nbsp; In order to get the map to show the right data according to the current timeslider timeextent, I followed the advice from&amp;nbsp;&lt;A href="https://gis.stackexchange.com/questions/372782/arcgis-js-api-time-series-with-heatmap" target="_self"&gt;this GIS stack exhange question&lt;/A&gt;&amp;nbsp;, and the layer's definitionExpression is updated with each timeslider change:&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;timeSlider.watch('timeExtent', function (value) {
		updateDefintionExpression(value);
});

function updateDefintionExpression(timeExtent) {
	const start = toDateString(timeExtent.start);
	const end = toDateString(timeExtent.end);
	covidLayer.definitionExpression = `Date &amp;gt;= DATE '${start}' AND Date &amp;lt;= DATE '${end}'`;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came up with a heatmap renderer from scratch, but it doesn't show off the low end as well as I'd like.&amp;nbsp; Here is the renderer code:&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;renderer: {
			type: 'heatmap',
			field: 'Confirmed',
			colorStops: [
				{ ratio: 0, color: 'rgba(255, 255, 255, 0)' },
				{ ratio: 0.06, color: 'rgba(255, 255, 255, 1)' },
				{ ratio: 0.15, color: 'rgba(255, 255, 0, 1)' },
				{ ratio: 0.25, color: 'rgba(255, 140, 0, 1)' },
				{ ratio: 0.55, color: 'rgba(255, 0, 0, 1)' },
			],
			minPixelIntensity: 1,
			maxPixelIntensity: 150000000,
			blurRadius: 12,
		},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see this in action here:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/poEdqEz" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/poEdqEz&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I played endlessly with the stops and the pixelIntensities, and I couldn't get a good range across the low end and high end (low numbers in the data vs high numbers in the data).&lt;/P&gt;&lt;P&gt;I looked into the JSON for the arcgis webmap I initially cereated, and this is the renderer it shows:&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;renderer: {
      type: "heatmap",
      blurRadius: 10,
      colorStops: [
        {
          ratio: 0,
          color: [212, 227, 245, 0]
        },
        {
          ratio: 0.01,
          color: [212, 227, 245, 0]
        },
        // ... more color stops
        {
          ratio: 0.9175000000000001,
          color: [204, 211, 51, 255]
        },
        {
          ratio: 1,
          color: [255, 255, 0, 255]
        }
      ],
      maxPixelIntensity: 9566880,
      minPixelIntensity: 0,
      field: "Confirmed"
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using that, I get this result:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/eYdebdp" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/eYdebdp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also not quite right - the low end looks nice, but the high end looks blown out, like the heatmap is overflowing against an invisible square border.&amp;nbsp; Take a look - here is my goal:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-26 at 9.10.04 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/2890iEF3544278FB01EA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-12-26 at 9.10.04 PM.png" alt="Screen Shot 2020-12-26 at 9.10.04 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But here is what I'm getting with the JS API:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-12-26 at 9.10.00 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/2891iF69D11EB744DBBB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2020-12-26 at 9.10.00 PM.png" alt="Screen Shot 2020-12-26 at 9.10.00 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure why in my handcoded app, the heatmap looks "cut off"...if I can fix this, then the renderer from JSON will probably work just fine.&amp;nbsp; (And how to get that nice fade-out effect?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried using the smartmapping heatmap renderer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  timeSlider.watch("timeExtent", function (value) {
    updateDefintionExpression(value);

    const params = {
       layer: covidLayer,
       view,
       field: "Confirmed",
       fadeToTransparent: true,
       minRatio: 0.05
    }

    heatmapRendererCreator.createRenderer(params)
    .then(result =&amp;gt; {
       covidLayer.renderer = result.renderer
       console.log(result.renderer)
    })
  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see the result here:&amp;nbsp;&lt;A href="https://codepen.io/slutske22/pen/VwKrqKr" target="_blank" rel="noopener"&gt;https://codepen.io/slutske22/pen/VwKrqKr&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This is also not correct.&amp;nbsp; This seems to re-evaluate the total range of values on each timeslider update, and distribute the heatmap accordingly, making each timestep look very similar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve the effect that I have in the arcgis online web map, using the JS API?&amp;nbsp; I feel I am close but struggling to see the right way.&lt;/P&gt;</description>
      <pubDate>Sun, 27 Dec 2020 05:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/difficulty-recreating-heatmap-renderer-with-time/m-p/1012375#M71195</guid>
      <dc:creator>SethLutske</dc:creator>
      <dc:date>2020-12-27T05:13:18Z</dc:date>
    </item>
  </channel>
</rss>

