Time

Incidents styled with a simple render, visual variables, and clusters to show number of days to close

What are time styles?

Time styles include all visualizations that involve date/time data. You can use these styles to visualize when and where an event occurs. Common examples involve the following:

  1. Timeline
  2. Before and after
  3. Age
  4. Time series filter
  5. Time series animation

How time styles work

The following examples describe how each time style works.

Examples

Timeline

A timeline visualization displays date/time data along a continuous color ramp. It provides an immediate view at when phenomena occurred or when a value was recorded relative to all other data points.

The following example visualizes hurricane locations in the Atlantic Ocean recorded in the year 2000. This uses a color visual variable to show which hurricanes occurred early in the season versus late in the season.

46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 47 48 49 50 51 52 53 54 55 56 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />

    <title> ArcGIS Developer Guide: Hurricane location and timeline </title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
    </style>

    <script>
      require([
        "esri/config",
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/Expand"
      ], function (esriConfig,WebMap, MapView, FeatureLayer, Legend, Expand) {
        esriConfig.apiKey = "YOUR_API_KEY";
        const renderer = {
          type: "simple",
          label: "Observed hurricane location",
          symbol: {
            type: "simple-marker",
            size: 6,
            outline: {
              width: 0.5,
              color: [255,255,255,0.5]
          visualVariables: [{
            type: "color",
            field: "Date_Time",
            legendOptions: {
              title: "Date of observation"
            },
            stops: [
              { value: new Date(2000, 7, 3).getTime(), color: "#00ffff"},
              { value: new Date(2000, 9, 22).getTime(), color: "#2f3f56"}
            ]
          }]
        const layer = new FeatureLayer({
          url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer/0",
          renderer: renderer
        const map = new WebMap({
          portalItem: {
            id: "9cf503b654144873a8e33f996f91ba1d"
          layers: [ layer ]
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 36978595,
          center: [ -44.0632, 33.1567 ],
          constraints: {
            snapToZoom:false
        view.ui.add(new Expand({
          content: new Legend({
            view: view
          view: view,
          expanded: true
        }), "top-right");
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

Before and after

You can use a color visual variable with a diverging color ramp to visualize which events occurred before and after a specific date.

The following example visualizes clusters of hurricane locations summarized by whether they occurred before or after January 1, 1977 on average.

44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 45 46 47 48 49 50 51 52 53 54 55 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />

    <title>ArcGIS Developer Guide: Hurricane locations before or after 1977</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
    </style>

    <script>
      require([
        "esri/config",
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/Expand"
      ], function (esriConfig,WebMap, MapView, FeatureLayer, Legend, Expand) {
        esriConfig.apiKey = "YOUR_API_KEY";
        const colors = [ "#54bebe", "#dedad2", "#c80064" ];
        const renderer = {
          type: "simple",
          label: "Observed hurricane location",
          symbol: {
            type: "simple-marker",
            size: 4,
            outline: null
          visualVariables: [{
            type: "color",
            field: "ISO_time",
            legendOptions: {
              title: "Before and after July 1"
            },
            stops: [
              { value: new Date(2013, 0, 1).getTime(), color: colors[0], label: "January 1" },
              { value: new Date(2013, 6, 1).getTime(), color: colors[1], label: "July 1" },
              { value: new Date(2013, 11, 31).getTime(), color: colors[2], label: "December 31" }
            ]
          }]
        // ISO_time
        const layer = new FeatureLayer({
          title: "2013 Hurricane season",
          portalItem: {
            id: "f14573e9c5ce4b41aecb199d5723209b"
          renderer: renderer,
          definitionExpression: "Season = 2013"
        const map = new WebMap({
          basemap: {
            portalItem: {
              id: "3967a92f547341e28636a8ac159666a3"
          layers: [ layer ]
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 136195673,
          constraints: {
            snapToZoom: false,
            rotationEnabled: false
        view.ui.add(new Expand({
          content: new Legend({
            view: view
          view: view,
          expanded: true
        }), "top-right");
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

Age

An age visualization shows the age of a feature (or the elapsed time up to a meaningful date or the current date) based on a date field. Age visualizations may be applied in the following scenarios:

  1. How long has an asset been in commission?
  2. How old is the incident report?
  3. How long has it been since the last inspection?
  4. Is an incident past due for resolution?

Age is typically defined using the DateDiff function in an Arcade expression and mapped with a color or size variable. It specifies a length of time with desired units.

 
1
valueExpression = "DateDiff( Now(), $feature.date_created, 'hours' )"

The following example visualizes clustered street condition complaints in New York City based on how much time passed before the incident was closed relative to its due date.

54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 55 56 57 58 59 60 61 62 63 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />

    <title> ArcGIS Developer Guide: Street condition complaints</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
    </style>

    <script>
      require([
        "esri/config",
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/Expand",
        "esri/smartMapping/labels/clusters",
        "esri/smartMapping/popup/clusters",
        "esri/core/promiseUtils"
      ], function (esriConfig,WebMap, MapView, FeatureLayer, Legend, Expand,
      ) {
        esriConfig.apiKey = "YOUR_API_KEY";
        const colors = [ "#2799ff", "#423a3a", "#ff3333" ];
        const renderer = {
          type: "simple",
          label: "Observed hurricane location",
          symbol: {
            type: "simple-marker",
            size: 6,
            outline: {
              width: 0.5,
              color: [255,255,255,0.5]
          visualVariables: [{
            type: "color",
            valueExpression: "DateDiff($feature['closed_time'], $feature['due_time'], 'days')",
            valueExpressionTitle: "Days it took to close incident",
            stops: [
              { value: -21, color: colors[0], label: "21 weeks early" },
              { value: 0, color: colors[1], label: "On time" },
              { value: 21, color: colors[2], label: "21 weeks late" }
            ]
          }]
        const layer = new FeatureLayer({
          portalItem: {
            id: "f624a9f4afa947fe98acd0ed38fbe436"
          title: "Street condition complaints",
          renderer: renderer,
          definitionExpression: "Complaint_Type = 'Street Condition'"
        const map = new WebMap({
          portalItem: {
            id: "75a3ce8990674a5ebd5b9ab66bdab893"
          layers: [ layer ]
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 144447,
          center: [ -73.863, 40.7 ],
          constraints: {
            snapToZoom:false
        view.ui.add(new Expand({
          content: new Legend({
            view: view
          view: view,
          expanded: true
        }), "top-right");
          .then(function(featureReduction){
          function generateClusterConfig() {
          // generates default popupTemplate
          const popupPromise = clusterPopupCreator
              layer: layer
            .then(function (popupTemplateResponse) {
              return popupTemplateResponse.primaryTemplate.value;
          // generates default labelingInfo
          const labelPromise = clusterLabelCreator
              layer: layer,
              view: view
            .then(function (labelSchemes) {
              return labelSchemes.primaryScheme;
          return promiseUtils
            .then(function (result) {
              const popupTemplate = result[0].value;
              const primaryLabelScheme = result[1].value;
              const labelingInfo = primaryLabelScheme.labelingInfo;
              // Ensures the clusters are large enough to fit labels
              const clusterMinSize = primaryLabelScheme.clusterMinSize;
              return {
                type: "cluster",
                popupTemplate: popupTemplate,
                labelingInfo: labelingInfo,
                clusterMinSize: clusterMinSize,
                clusterRadius: 50
            .catch(function (error) {
              console.error(error);
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>

Time series filter

In most cases, time series animations involve assigning a layer a static renderer and filtering features over time. This is effective for features whose positions occur only at specific moments or windows of time (e.g. earthquakes, hurricanes, airplane travel). This requires a TimeSlider widget for control over the time window.

The layer in this example is rendered with a simple renderer and an animated gif showing a rotating hurricane symbol. This layer shows the current position of a hurricane relative to the slider thumb positions. Another layer is added to show the previous positions of the hurricanes relative to the time slider values.

ArcGIS JS API
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66 66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />

    <title>ArcGIS Developer Guide: Time series filter</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      #timeSlider {
        position: absolute;
        left: 100px;
        right: 100px;
        bottom: 30px;
    </style>

    <script>
      require([
        "esri/config",
        "esri/WebMap",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend",
        "esri/widgets/TimeSlider",
        "esri/widgets/Expand"
      ], function (esriConfig,WebMap, MapView, FeatureLayer, Legend, TimeSlider, Expand) {
        esriConfig.apiKey = "YOUR_API_KEY";
        const year = 2005;
        const renderer = {
          type: "simple",
          label: "Observed hurricane location",
          symbol: {
            type: "picture-marker",
            url: "/javascript/latest/assets/img/guide/visualization/demos/cyclone-marker.gif",
            height: 20,
            width: 20
          },
          visualVariables: [{
            type: "size",
            field: "Category",
            stops: [
              { value: 1, size: 12 },
              { value: 2, size: 16 },
              { value: 3, size: 20 },
              { value: 4, size: 24 },
              { value: 5, size: 28 }
            ]
          }]
        };
        const layer = new FeatureLayer({
          title: `${year} Hurricane season`,
          portalItem: {
            id: "f14573e9c5ce4b41aecb199d5723209b"
          renderer: renderer,
          definitionExpression: `Season = ${year}`
        const trackRenderer = {
          type: "simple",
          label: "Previous hurricane location",
          symbol: {
            type: "simple-marker",
            color: "rgba(188,46,28,0.05)",
            size: 4,
            outline: null
          visualVariables: [{
            type: "size",
            field: "Category",
            legendOptions: {
              showLegend: false
            stops: [
              { value: 1, size: 4 },
              { value: 2, size: 8 },
              { value: 3, size: 10 },
              { value: 4, size: 12 },
              { value: 5, size: 18 }
        const trackLayer = new FeatureLayer({
          title: `${year} Hurricane season`,
          portalItem: {
            id: "f14573e9c5ce4b41aecb199d5723209b"
          renderer: trackRenderer,
          useViewTime: false,
          definitionExpression: `Season = ${year}`
        const map = new WebMap({
          basemap: {
            portalItem: {
              id: "3967a92f547341e28636a8ac159666a3"
          layers: [ layer, trackLayer ]
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 136195673,
          constraints: {
            snapToZoom: false,
            rotationEnabled: false
        view.ui.add(new Expand({
          content: new Legend({
            view: view
          view: view,
          expanded: false
        }), "top-right");
        const start = new Date(year-1, 9, 1);
        const end = new Date(year+1, 0, 15);
        const next = new Date(year-1, 9, 1, 7);
        const timeSlider = new TimeSlider({
          container: "timeSlider",
          playRate: 30,
          mode: "time-window",
          fullTimeExtent: {
          values: [ start, next ],
          stops: {
            interval: {
              value: 6,
              unit: "hours"
          view: view
        view.ui.add(timeSlider, "manual");
        view.whenLayerView(trackLayer).then(function(trackLayerView){
            timeExtent: {
              end: timeSlider.values[1]
          timeSlider.watch("values", function(values){
              timeExtent: {
                end: values[1]
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
    <div id="timeSlider"></div>
  </body>
</html>

Time series animation

Time series animations are animated visualizations showing how features in a dataset change over time based on location and/or a data attribute's value. These typically involve a time slider so users have the ability to explore moments of time or time windows.

For features that have a static position (such as sensors, buildings, countries, etc.), but that have attributes that vary over time (e.g. population, temperature, windspeed), you can dynamically update the renderer to reference data values tied to a specific moment in time, rather than filter features. This removes the need for downloading duplicate geometries to the client.

The renderer udpates with every slider value change.

288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 288 289 290 291 292 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293 293
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>ArcGIS Developer Guide: Time series animation</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      #containerDiv {
        padding: 10px;
        text-align: center;
        box-shadow: 0;
      #sliderDiv {
        height: 100px;
      #histogram {
        width: 500px;
        height: 150px;
      .labels {
        padding: 5px;
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      #viewDiv {
        position: absolute;
        right: 0;
        left: 0;
        top: 0;
        bottom: 100px;
      #sliderContainer {
        position: absolute;
        bottom: 0;
        height: 100px;
        width: 100%;
        text-align: center;
    </style>

    <script id="highest-temp-arcade" type="arcgis/arcade">
      var highest = -Infinity;
      var ignoreFields = [ "OBJECTID", "x", "y", "Range" ];
      for (var att in $feature){
        var value = $feature[att];
        if( typeof(value) == 'Number' && IndexOf(ignoreFields, att) == -1){
      return highest;
    </script>

    <script id="lowest-temp-arcade" type="arcgis/arcade">
      var lowest = Infinity;
      var ignoreFields = [ "OBJECTID", "x", "y", "Range" ];
      for (var att in $feature){
        var value = $feature[att];
        if( typeof(value) == 'Number' && IndexOf(ignoreFields, att) == -1){
      return lowest;
    </script>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/smartMapping/statistics/histogram",
        "esri/smartMapping/statistics/summaryStatistics",
        "esri/widgets/Histogram",
        "esri/widgets/Slider",
        "esri/widgets/Legend",
        "esri/widgets/Expand",
        "esri/core/watchUtils",
        "esri/Color"
      ], function (
        Map,
      ) {
        esriConfig.apiKey = "YOUR_API_KEY";
        // Project base layer (world countries) to Equal Earth projection
        const baseLayer = new FeatureLayer({
          portalItem: {
            id: "2b93b06dc0dc4e809d3c8db5cb96ba69"
          legendEnabled: false,
          popupEnabled: false,
          renderer: {
            type: "simple",
            symbol: {
              type: "simple-fill",
              color: [200, 200, 200, 0.75],
              outline: null
        // Set initial temperature anomaly renderer on layer based
        // on data recorded for the year 1880
        const layer = new FeatureLayer({
          url: "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/Global_Temperatures_1880_to_2018/FeatureServer/0",
          outFields: ["*"],
          title: "Temperatures by location (1880 - 2018)",
          renderer: {
            type: "simple",
            label: "Observation point",
            symbol: {
              type: "simple-marker",
              style: "diamond",
              size: "6px",
              color: [226, 226, 226, 0.75],
              outline: {
                color: [255, 255, 255, 0.25],
                width: "0.75px"
            visualVariables: [
                type: "size",
                valueExpression: getSizeValueExpression(1880),
                valueExpressionTitle: "Absolute Value",
                legendOptions: {
                  showLegend: false
                maxDataValue: 35,
                maxSize: "24px",
                minDataValue: 10,
                minSize: "4px"
                type: "color",
                field: getColorField(1880),
                legendOptions: {
                  title: "Temperature Anomaly"
                stops: [
                    value: -2.5,
                    color: [5, 112, 176, 0.75],
                    label: "Less than -2.5 deg C"
                  { value: -1, color: [208, 209, 230, 0.75] },
                  { value: -0.5, color: [236, 231, 242, 0.75] },
                    value: 0,
                    color: [226, 226, 226, 0.75],
                    label: "No difference/No Data"
                  { value: 0.5, color: [254, 232, 200, 0.75] },
                  { value: 1, color: [253, 212, 158, 0.75] },
                    value: 2.5,
                    color: [215, 48, 31, 0.75],
                    label: "More than 2.5 deg C"
          popupTemplate: {
            expressionInfos: [
                name: "max",
                title: "Warmest anomaly",
                expression: document.getElementById("highest-temp-arcade")
                name: "min",
                title: "Coldest anomaly",
                expression: document.getElementById("lowest-temp-arcade")
            content: [
                type: "fields",
                fieldInfos: [
                    fieldName: "expression/max",
                    format: {
                      places: 2
                    fieldName: "expression/min",
                    format: {
                      places: 2
        const map = new Map({
          layers: [baseLayer, layer]
        const spatialReference = {
          wkid: 54035
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 150000000,
          center: { x: 0, y: 0, spatialReference: spatialReference },
          spatialReference: spatialReference,
          popup: {
            dockOptions: {
              position: "top-left"
          constraints: {
            snapToZoom:false
          new Expand({
            view: view,
            content: document.getElementById("containerDiv"),
            expanded: false,
            expandIconClass: "esri-icon-chart"
          "top-right"
        // This slider will allow the user to update the renderer based on a
        // provided year between 1880 and 2018
        const slider = new Slider({
          min: 1880,
          max: 2018,
          values: [ 1880 ],
          visibleElements: {
            labels: true,
            rangeLabels: true
          labelInputsEnabled: true,
          precision: 0,
          steps: 1,
          container: "sliderDiv"
        // When the user changes the slider's value,
        // change the renderer and histogram to reflect
        // data corresponding to the year indicated on the slider
        slider.on(["thumb-change", "thumb-drag"], function (event) {
          updateRenderer(event.value);
          updateHistogram(event.value);
          updateYearDisplay(event.value);
        });
        let points = null;
        let lv = null;
        // Query all the features in the layer. These will by used
        // for client-side queries as the user slides the thumb of the slider
          .then(function (layerView) {
            watchUtils.whenFalseOnce(layerView, "updating", function () {
              return layerView
                .then(function (response) {
                  const year = slider.values[0];
                .catch(function (e) {
                  console.error(e);
          .catch(function (e) {
            console.error(e);
        // Updates the underlying data value driving the expression
        // based on the given year provided by the slider
        function updateRenderer(value) {
          const renderer = layer.renderer.clone();
          const sizeVariable = renderer.visualVariables[0];
          const colorVariable = renderer.visualVariables[1];
          colorVariable.field = "F" + value;
        // Generate color visual variable based on the given year
        function getColorField(value) {
          return "F" + value;
        // Generate size visual variable based on the given year
        // This is the same expression as "size-arcade" above, but
        // modifiable for any given year
        function getSizeValueExpression(value) {
          return `
            var AbsTEMP = Abs($feature.F${value});
          `
        let histograms = {};
        let histogramChart = null;
        const histMin = -5;
        const histMax = 5;
        let highlight;
        function getAverage(params) {
          return summaryStatistics(params).then(function (statistics) {
            return statistics.avg;
        function updateHistogram(year) {
          if (histograms[year]) {
          // params for generating a histogram using the
          // points available on the client
          const params = {
            layer: layer,
            field: "F" + year,
            view: view,
            features: points,
            numBins: 100,
            minValue: histMin,
            maxValue: histMax
          let average = null;
            .then(function (avg) {
              return histogram(params);
            .then(function (histogramResult) {
              // cache previously used histograms to improve performance
              if (!histogramChart) {
                histogramChart = new Histogram({
                  container: "histogram",
                  min: histMin,
                  max: histMax,
                  bins: histogramResult.bins,
                  average: average,
                  dataLines: [
                      value: 0
                  dataLineCreatedFunction: function (element, label, index) {
                    if (index === 0) {
                      element.setAttribute("y2", "75%");
                  labelFormatFunction: function (value, type) {
                    return type === "average" ? value.toFixed(2) + "°" : value;
                  barCreatedFunction: function (index, element) {
                    const bin = histogramChart.bins[index];
                    const midValue =
                      (bin.maxValue - bin.minValue) / 2 + bin.minValue;
                    const color = getColorFromValue(midValue);
                    element.setAttribute("fill", color.toHex());
                    element.addEventListener("focus", function () {
                      const { minValue, maxValue, count } = bin;
                      const query = lv.layer.createQuery();
                      const field = "F" + slider.values[0];
                      query.where = `${field} >= ${minValue} AND ${field} <= ${maxValue}`;
                      lv.queryObjectIds(query).then(function (ids) {
                        if (highlight) {
                          highlight = null;
                    element.addEventListener("blur", function () {
                      if (highlight) {
                        highlight = null;
              } else {
            .catch(function (e) {
              console.error(e);
        // Infers the color of the visual variable based on a given value
        // This is used to render and update histogram bars with colors
        // matching the features in the map
        function getColorFromValue(value) {
          const visualVariable = layer.renderer.visualVariables.filter(
            function (vv) {
              return vv.type === "color";
          )[0];
          const stops = visualVariable.stops;
          let minStop = stops[0];
          let maxStop = stops[stops.length - 1];
          let minStopValue = minStop.value;
          let maxStopValue = maxStop.value;
          if (value < minStopValue) {
            return minStop.color;
          if (value > maxStopValue) {
            return maxStop.color;
          const exactMatches = stops.filter(function (stop) {
            return stop.value === value;
          if (exactMatches.length > 0) {
            return exactMatches[0].color;
          minStop = null;
          maxStop = null;
          stops.forEach(function (stop, i) {
            if (!minStop && !maxStop && stop.value >= value) {
              minStop = stops[i - 1];
          const weightedPosition =
          return Color.blendColors(
        function updateYearDisplay(year) {
          const yearElement = document.getElementById("yearDiv");
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
    <div id="containerDiv" class="esri-widget">
      <div class="esri-widget">
        <div id="title" class="esri-widget">
          <h3>Temperature Anomaly (<span id="yearDiv">1880</span>)</h3>
        </div>
        <div id="histogram" class="esri-widget"></div>
        <div class="labels esri-widget">
          <span style="float: left">-5° C</span>
          <span style="float: center">0° C</span>
          <span style="float: right">+5° C</span>
        </div>
      </div>
    </div>
    <div id="sliderContainer" class="esri-widget">
      <div id="sliderDiv"></div>
    </div>
  </body>
</html>
327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 328 329 330 331 332 333 334 335 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336 336
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>ArcGIS Developer Guide: Time series animation</title>

    <link rel="stylesheet" href="https://js.arcgis.com/4.19/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.19/"></script>

    <style>
      #containerDiv {
        padding: 10px;
        text-align: center;
        box-shadow: 0;
      #sliderDiv {
        height: 100px;
      #histogram {
        width: 500px;
        height: 150px;
      .labels {
        padding: 5px;
      html,
      body {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      #viewDiv {
        position: absolute;
        right: 0;
        left: 0;
        top: 0;
        bottom: 100px;
      #sliderContainer {
        position: absolute;
        bottom: 0;
        height: 100px;
        width: 100%;
        text-align: center;
    </style>

    <script id="highest-temp-arcade" type="arcgis/arcade">
      var highest = -Infinity;
      var ignoreFields = [ "OBJECTID", "x", "y", "Range" ];
      for (var att in $feature){
        var value = $feature[att];
        if( typeof(value) == 'Number' && IndexOf(ignoreFields, att) == -1){
      return highest;
    </script>

    <script id="lowest-temp-arcade" type="arcgis/arcade">
      var lowest = Infinity;
      var ignoreFields = [ "OBJECTID", "x", "y", "Range" ];
      for (var att in $feature){
        var value = $feature[att];
        if( typeof(value) == 'Number' && IndexOf(ignoreFields, att) == -1){
      return lowest;
    </script>

    <script>
      require([
        "esri/config",
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/smartMapping/statistics/histogram",
        "esri/smartMapping/statistics/summaryStatistics",
        "esri/widgets/Histogram",
        "esri/widgets/Slider",
        "esri/widgets/Legend",
        "esri/widgets/Expand",
        "esri/core/watchUtils",
        "esri/Color"
      ], function (
        Map,
      ) {
        esriConfig.apiKey = "YOUR_API_KEY";
        // Project base layer (world countries) to Equal Earth projection
        const baseLayer = new FeatureLayer({
          portalItem: {
            id: "2b93b06dc0dc4e809d3c8db5cb96ba69"
          legendEnabled: false,
          popupEnabled: false,
          renderer: {
            type: "simple",
            symbol: {
              type: "simple-fill",
              color: [200, 200, 200, 0.75],
              outline: null
        // Set initial temperature anomaly renderer on layer based
        // on data recorded for the year 1880
        const layer = new FeatureLayer({
          url: "https://services.arcgis.com/jIL9msH9OI208GCb/arcgis/rest/services/Global_Temperatures_1880_to_2018/FeatureServer/0",
          outFields: ["*"],
          title: "Temperatures by location (1880 - 2018)",
          renderer: {
            type: "simple",
            label: "Observation point",
            symbol: {
              type: "simple-marker",
              style: "diamond",
              size: "6px",
              color: [226, 226, 226, 0.75],
              outline: {
                color: [255, 255, 255, 0.25],
                width: "0.75px"
            visualVariables: [
                type: "size",
                valueExpression: getSizeValueExpression(1880),
                valueExpressionTitle: "Absolute Value",
                legendOptions: {
                  showLegend: false
                maxDataValue: 35,
                maxSize: "24px",
                minDataValue: 10,
                minSize: "4px"
                type: "color",
                field: getColorField(1880),
                legendOptions: {
                  title: "Temperature Anomaly"
                stops: [
                    value: -2.5,
                    color: [5, 112, 176, 0.75],
                    label: "Less than -2.5 deg C"
                  { value: -1, color: [208, 209, 230, 0.75] },
                  { value: -0.5, color: [236, 231, 242, 0.75] },
                    value: 0,
                    color: [226, 226, 226, 0.75],
                    label: "No difference/No Data"
                  { value: 0.5, color: [254, 232, 200, 0.75] },
                  { value: 1, color: [253, 212, 158, 0.75] },
                    value: 2.5,
                    color: [215, 48, 31, 0.75],
                    label: "More than 2.5 deg C"
          popupTemplate: {
            expressionInfos: [
                name: "max",
                title: "Warmest anomaly",
                expression: document.getElementById("highest-temp-arcade")
                name: "min",
                title: "Coldest anomaly",
                expression: document.getElementById("lowest-temp-arcade")
            content: [
                type: "fields",
                fieldInfos: [
                    fieldName: "expression/max",
                    format: {
                      places: 2
                    fieldName: "expression/min",
                    format: {
                      places: 2
        const map = new Map({
          layers: [baseLayer, layer]
        const spatialReference = {
          wkid: 54035
        const view = new MapView({
          container: "viewDiv",
          map: map,
          scale: 150000000,
          center: { x: 0, y: 0, spatialReference: spatialReference },
          spatialReference: spatialReference,
          popup: {
            dockOptions: {
              position: "top-left"
          constraints: {
            snapToZoom:false
          new Expand({
            view: view,
            content: document.getElementById("containerDiv"),
            expanded: false,
            expandIconClass: "esri-icon-chart"
          "top-right"
        // This slider will allow the user to update the renderer based on a
        // provided year between 1880 and 2018
        const slider = new Slider({
          min: 1880,
          max: 2018,
          values: [ 1880 ],
          visibleElements: {
            labels: true,
            rangeLabels: true
          labelInputsEnabled: true,
          precision: 0,
          steps: 1,
          container: "sliderDiv"
        // When the user changes the slider's value,
        // change the renderer and histogram to reflect
        // data corresponding to the year indicated on the slider
        slider.on(["thumb-change", "thumb-drag"], function (event) {
        let points = null;
        let lv = null;
        // Query all the features in the layer. These will by used
        // for client-side queries as the user slides the thumb of the slider
          .then(function (layerView) {
            watchUtils.whenFalseOnce(layerView, "updating", function () {
              return layerView
                .then(function (response) {
                  const year = slider.values[0];
                .catch(function (e) {
                  console.error(e);
          .catch(function (e) {
            console.error(e);
        // Updates the underlying data value driving the expression
        // based on the given year provided by the slider
        function updateRenderer(value) {
          const renderer = layer.renderer.clone();
          const sizeVariable = renderer.visualVariables[0];
          const colorVariable = renderer.visualVariables[1];
          sizeVariable.valueExpression = getSizeValueExpression(value);
          colorVariable.field = "F" + value;
          renderer.visualVariables = [sizeVariable, colorVariable];
          layer.renderer = renderer;
        }
        // Generate color visual variable based on the given year
        function getColorField(value) {
          return "F" + value;
        // Generate size visual variable based on the given year
        // This is the same expression as "size-arcade" above, but
        // modifiable for any given year
        function getSizeValueExpression(value) {
          return `
            var AbsTEMP = Abs($feature.F${value});
          `
        let histograms = {};
        let histogramChart = null;
        const histMin = -5;
        const histMax = 5;
        let highlight;
        function getAverage(params) {
          return summaryStatistics(params).then(function (statistics) {
            return statistics.avg;
        function updateHistogram(year) {
          if (histograms[year]) {
          // params for generating a histogram using the
          // points available on the client
          const params = {
            layer: layer,
            field: "F" + year,
            view: view,
            features: points,
            numBins: 100,
            minValue: histMin,
            maxValue: histMax
          let average = null;
            .then(function (avg) {
              return histogram(params);
            .then(function (histogramResult) {
              // cache previously used histograms to improve performance
              if (!histogramChart) {
                histogramChart = new Histogram({
                  container: "histogram",
                  min: histMin,
                  max: histMax,
                  bins: histogramResult.bins,
                  average: average,
                  dataLines: [
                      value: 0
                  dataLineCreatedFunction: function (element, label, index) {
                    if (index === 0) {
                      element.setAttribute("y2", "75%");
                  labelFormatFunction: function (value, type) {
                    return type === "average" ? value.toFixed(2) + "°" : value;
                  barCreatedFunction: function (index, element) {
                    const bin = histogramChart.bins[index];
                    const midValue =
                      (bin.maxValue - bin.minValue) / 2 + bin.minValue;
                    const color = getColorFromValue(midValue);
                    element.setAttribute("fill", color.toHex());
                    element.addEventListener("focus", function () {
                      const { minValue, maxValue, count } = bin;
                      const query = lv.layer.createQuery();
                      const field = "F" + slider.values[0];
                      query.where = `${field} >= ${minValue} AND ${field} <= ${maxValue}`;
                      lv.queryObjectIds(query).then(function (ids) {
                        if (highlight) {
                          highlight = null;
                    element.addEventListener("blur", function () {
                      if (highlight) {
                        highlight = null;
              } else {
            .catch(function (e) {
              console.error(e);
        // Infers the color of the visual variable based on a given value
        // This is used to render and update histogram bars with colors
        // matching the features in the map
        function getColorFromValue(value) {
          const visualVariable = layer.renderer.visualVariables.filter(
            function (vv) {
              return vv.type === "color";
          )[0];
          const stops = visualVariable.stops;
          let minStop = stops[0];
          let maxStop = stops[stops.length - 1];
          let minStopValue = minStop.value;
          let maxStopValue = maxStop.value;
          if (value < minStopValue) {
            return minStop.color;
          if (value > maxStopValue) {
            return maxStop.color;
          const exactMatches = stops.filter(function (stop) {
            return stop.value === value;
          if (exactMatches.length > 0) {
            return exactMatches[0].color;
          minStop = null;
          maxStop = null;
          stops.forEach(function (stop, i) {
            if (!minStop && !maxStop && stop.value >= value) {
              minStop = stops[i - 1];
          const weightedPosition =
          return Color.blendColors(
        function updateYearDisplay(year) {
          const yearElement = document.getElementById("yearDiv");
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
    <div id="containerDiv" class="esri-widget">
      <div class="esri-widget">
        <div id="title" class="esri-widget">
          <h3>Temperature Anomaly (<span id="yearDiv">1880</span>)</h3>
        </div>
        <div id="histogram" class="esri-widget"></div>
        <div class="labels esri-widget">
          <span style="float: left">-5° C</span>
          <span style="float: center">0° C</span>
          <span style="float: right">+5° C</span>
        </div>
      </div>
    </div>
    <div id="sliderContainer" class="esri-widget">
      <div id="sliderDiv"></div>
    </div>
  </body>
</html>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.