Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <!--
     ArcGIS API for JavaScript, https://js.arcgis.com
     For more information about the visualization-classbreaks sample,
     read the original sample description at developers.arcgis.com.
     https://developers.arcgis.com/javascript/latest/sample-code/visualization-classbreaks/
     -->
    <title>
      Visualize data with class breaks | Sample | ArcGIS API for JavaScript 4.24
    </title>

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

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

    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer",
        "esri/widgets/Legend"
      ], (Map, MapView, FeatureLayer, Legend) => {
        /*****************************************************************
         * Define symbols for each class break.
         *****************************************************************/

        const less35 = {
          type: "simple-fill", // autocasts as new SimpleFillSymbol()
          color: "#fffcd4",
          style: "solid",
          outline: {
            width: 0.2,
            color: [255, 255, 255, 0.5]
          }
        };

        const less50 = {
          type: "simple-fill", // autocasts as new SimpleFillSymbol()
          color: "#b1cdc2",
          style: "solid",
          outline: {
            width: 0.2,
            color: [255, 255, 255, 0.5]
          }
        };

        const more50 = {
          type: "simple-fill", // autocasts as new SimpleFillSymbol()
          color: "#38627a",
          style: "solid",
          outline: {
            width: 0.2,
            color: [255, 255, 255, 0.5]
          }
        };

        const more75 = {
          type: "simple-fill", // autocasts as new SimpleFillSymbol()
          color: "#0d2644",
          style: "solid",
          outline: {
            width: 0.2,
            color: [255, 255, 255, 0.5]
          }
        };

        /*****************************************************************
         * Set each unique value directly in the renderer's constructor.
         * At least one field must be used (in this case the "COL_DEG" field).
         * The label property of each unique value will be used to indicate
         * the field value and symbol in the legend.
         *****************************************************************/

        const renderer = {
          type: "class-breaks", // autocasts as new ClassBreaksRenderer()
          field: "COL_DEG",
          normalizationField: "EDUCBASECY",
          legendOptions: {
            title: "% of adults (25+) with a college degree"
          },
          defaultSymbol: {
            type: "simple-fill", // autocasts as new SimpleFillSymbol()
            color: "black",
            style: "backward-diagonal",
            outline: {
              width: 0.5,
              color: [50, 50, 50, 0.6]
            }
          },
          defaultLabel: "no data",
          classBreakInfos: [
            {
              minValue: 0,
              maxValue: 0.3499,
              symbol: less35,
              label: "< 35%"
            },
            {
              minValue: 0.35,
              maxValue: 0.4999,
              symbol: less50,
              label: "35 - 50%"
            },
            {
              minValue: 0.5,
              maxValue: 0.7499,
              symbol: more50,
              label: "50 - 75%"
            },
            {
              minValue: 0.75,
              maxValue: 1.0,
              symbol: more75,
              label: "> 75%"
            }
          ]
        };

        const seattleLayer = new FeatureLayer({
          url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Puget_Sound_BG_demographics/FeatureServer/0",
          title: "Seattle block groups",
          renderer: renderer,
          popupTemplate: {
            // autocast as esri/PopupTemplate
            title: "Block Group {FID_Block_Group}",
            content:
              "{COL_DEG} adults 25 years old and older in this block group have a college degree. " +
              "{NO_COL_DEG} adults do not have a college degree."
          },
          // show only block groups in Seattle
          definitionExpression: "City = 'Seattle' AND EDUCBASECY > 0",
          opacity: 0.9
        });

        const map = new Map({
          basemap: "gray-vector",
          layers: [seattleLayer]
        });

        const view = new MapView({
          container: "viewDiv",
          map: map,
          center: [-122.3487846, 47.58907],
          zoom: 11
        });

        /******************************************************************
         *
         * Add layers to layerInfos on the legend
         *
         ******************************************************************/

        const legend = new Legend({
          view: view
        });

        view.ui.add(legend, "bottom-left");

        view.when().then(async () => {
          const labels = view.map.basemap.referenceLayers.removeAt(0);
          view.map.layers.splice(0, 0, labels);
        });
      });
    </script>
  </head>

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

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console