Pen Settings



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


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


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.


Save Automatically?

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.


  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>Dot Density Renderer</title>
    html, body, #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
  <link rel="stylesheet" href="">
  <script src=""></script>
      ], function(WebMap, MapView,FeatureLayer,DotDensityRenderer,Legend) {
const map = new WebMap({ //we load directly a webmap that contains only a basemap, we will enrich this webmap with a layer, a layer
          portalItem: {
            id: "56b5bd522c52409c90d902285732e9f1"
      var view = new MapView({
        container: "viewDiv",
        map: map,
        center: [3,46],
        //zoom: 10,
        constraints: { //prevents zooming too much
            maxScale: 100000
     var PortalItem = new FeatureLayer({
        portalItem: {
          id: "a256c9833cc2465fbfb707959f1d82b4"
        PortalItem.renderer = {
  type: "dot-density",  // autocasts as new DotDensityRenderer()
  referenceDotValue: 100,  // 1 dot = 1,000 people when the view.scale is 1:1,000,000
  referenceScale: 3000000,  // view.scale
    legendOptions: {
    unit: "personnes"
          attributes: [{
    field: "CSP_PopActive_Cadres_Actifs",
    label: "Cadres actifs",
    color: "#f23c3f" //blue
  }, {
    field: "CSP_PopActive_Ouvriers_Actifs",
    label: "Ouvriers actifs",
    color: "#96f7ef" //red #00b6f1 
    field: "CSP_PopActive_Artisans_commerça",
    label: "Artisants, commerçants et chefs d'entreprises actifs",
    color: "#ff50dd"
    field: "CSP_PopActive_Employés_Actifs",
    label: "Employés Actifs",
    color: "#ffff00" //pink #ff7fe9
    field: "CSP_PopActive_Professions_inter",
    label: "Professions intermédiaires Actifs",
    color: "#00FF00" //orange
      map.add(PortalItem, 1);
var legend = new Legend({
  view: view,
  layerInfos: [{
    layer: PortalItem,
    title: "Légende"

view.ui.add(legend, "bottom-right");
  <div id="viewDiv"></div>