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"/>
    <title>
      Size visual variable themes | Sample | ArcGIS API for JavaScript 4.18
    </title>

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

  </head>

  <body>
    <div id="viewDiv"></div>
    <div id="container-div" class="esri-widget">
      <div id="theme-container" class="esri-widget">
        <div id="size-theme-container">
          Select size theme:
          <select id="size-theme-select">
            <option value="high-to-low">high to low</option>
            <option value="above">above</option>
            <option value="below">below</option>
            <option value="above-and-below" selected>above-and-below</option>
          </select>
        </div>
        <div id="symbol-style-container">
          Select symbol style:
          <select id="symbol-style-select">
            <option value="none">none</option>
            <option value="caret">caret</option>
            <option value="circle-caret">circle-caret</option>
            <option value="arrow">arrow</option>
            <option value="circle-arrow" selected>circle-arrow</option>
            <option value="plus-minus">plus-minus</option>
            <option value="circle-plus-minus">circle-plus-minus</option>
            <option value="square">square</option>
            <option value="circle" selected>circle</option>
            <option value="triangle">triangle</option>
            <option value="house">house</option>
          </select>
        </div>
      </div>
      <div id="legend-container"></div>
    </div>
  </body>
</html>

              
            
!

CSS

              
                html,
body,
#viewDiv {
  padding: 0;
  margin: 0;
  height: 100%;
  width: 100%;
}
#size-theme-container {
  padding: 10px 10px 5px 10px;
}
#symbol-style-container {
  padding: 5px 10px 5px 10px;
}
              
            
!

JS

              
                require([
  "esri/Map",
  "esri/views/MapView",
  "esri/layers/FeatureLayer",
  "esri/smartMapping/renderers/size",
  "esri/smartMapping/renderers/univariateColorSize",
  "esri/widgets/Legend",
  "esri/symbols/WebStyleSymbol",
  "esri/core/watchUtils"
], function (
  Map,
  MapView,
  FeatureLayer,
  sizeRendererCreator,
  univariateRendererCreator,
  Legend,
  WebStyleSymbol,
  watchUtils
) {
  const layer = new FeatureLayer({
    title: "Census tracts",
    portalItem: {
      id: "936481805c2d4639ac727938b32d8ec3"
    },
    layerId: 2,
    minScale: 0,
    maxScale: 0,
    opacity: 0.01
  });

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

  const view = new MapView({
    container: "viewDiv",
    map,
    center: [-83.0208, 42.4388],
    scale: 543438,
    constraints: {
      snapToZoom: false
    }
  });

  view.when(async () => {
    const layerView = await view.whenLayerView(layer);
    watchUtils.whenFalseOnce(layerView, "updating", updateLayer);
  });

  const legend = new Legend({
    view,
    container: document.getElementById("legend-container")
  });
  view.ui.add("container-div", "bottom-right");

  const themeSelect = document.getElementById("size-theme-select");
  themeSelect.addEventListener("change", updateLayer);

  const symbolSelect = document.getElementById("symbol-style-select");
  symbolSelect.addEventListener("change", updateLayer);

  const symbolStyleContainer = document.getElementById(
    "symbol-style-container"
  );

  // update the layer's renderer each time the user changes a parameter
  async function updateLayer() {
    const theme = themeSelect.value;
    const symbolStyle = symbolSelect.value;
    symbolStyleContainer.style.display =
      theme === "above-and-below" ? "block" : "none";

    const renderer = await createRenderer({ theme, symbolStyle });
    layer.renderer = renderer;
    layer.opacity = 1;
  }

  async function createRenderer({ theme, symbolStyle }) {
    // Update the legend title based on the selected theme
    const legendTitles = {
      above: `Increase in number of households 2000-2010`,
      below: `Decline in number of households 2000-2010`,
      "above-and-below": `Change in number of households 2000-2010`
    };

    const houseSymbol = new WebStyleSymbol({
      name: "house",
      styleName: "Esri2DPointSymbolsStyle"
    });
    
    const houseCIM = await houseSymbol.fetchCIMSymbol();

    let params = {
      layer,
      view,
      theme,
      valueExpression: `$feature.TOTHU10 - $feature.TOTHU00`,
      valueExpressionTitle: legendTitles[theme],
      minValue: -1000,
      maxValue: 2000,
      defaultSymbolEnabled: false,
      colorOptions: {
        isContinuous: false
      }
    };

    if (theme === "above-and-below") {
      params.symbolOptions =
        symbolStyle !== "none" || symbolStyle !== "house"
          ? {
              symbolStyle
            }
          : null;
      if (symbolStyle === "house") {
        params.symbolOptions = {
          symbols: {
            above: houseCIM,
            below: houseCIM.clone()
          }
        };
      }
      const {
        renderer
      } = await univariateRendererCreator.createContinuousRenderer(
        params
      );
      const colorVV = renderer.visualVariables.filter(
        (vv) => vv.type === "color"
      )[0];
      // colorVV.stops[0].value = -953;
      return renderer;
    } else {
      const {
        renderer
      } = await sizeRendererCreator.createContinuousRenderer(params);
      return renderer;
    }
  }
});
              
            
!
999px

Console