Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/maps.js"></script>
<script src="https://www.amcharts.com/lib/4/geodata/worldHigh.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<script src="https://www.amcharts.com/lib/4/plugins/bullets.js"></script>
<div id="chartdiv"></div>
              body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

#chartdiv {
  width: 100%;
  height: 500px;
 * ---------------------------------------
 * This demo was created using amCharts 4.
 * For more information visit:
 * https://www.amcharts.com/
 * Documentation is available at:
 * https://www.amcharts.com/docs/v4/
 * ---------------------------------------

// Themes

// Create map instance
var chart = am4core.create("chartdiv", am4maps.MapChart);

// Set map definition
chart.geodata = am4geodata_worldHigh;

// Set projection
chart.projection = new am4maps.projections.Mercator();

// Center on the groups by default
chart.homeZoomLevel = 6;
chart.homeGeoPoint = { longitude: 10, latitude: 51 };

// Polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
polygonSeries.exclude = ["AQ"];
polygonSeries.useGeodata = true;
polygonSeries.nonScalingStroke = true;
polygonSeries.strokeOpacity = 0.5;
polygonSeries.dataFields.value = "value";

// Image series
var imageSeries = chart.series.push(new am4maps.MapImageSeries());
var imageTemplate = imageSeries.mapImages.template;
imageTemplate.propertyFields.longitude = "longitude";
imageTemplate.propertyFields.latitude = "latitude";
imageTemplate.nonScaling = true;

// Creating a pin bullet
var pin = imageTemplate.createChild(am4plugins_bullets.PinBullet);

// Set what to display on rollover tooltip
pin.tooltipText = "{title}";
imageSeries.tooltip.pointerOrientation = "right";

// Configuring pin appearance
pin.background.fill = chart.colors.getIndex(0);
pin.background.fillOpacity = 0.7;
pin.background.pointerAngle = 120;
pin.background.pointerBaseWidth = 10;

// Adding an image with its "href" attribute tied to values in data
pin.image = new am4core.Image();
pin.image.propertyFields.href = "imageURL";

// Creating a "heat rule" to modify "radius" of the bullet based
// on value in data
 "target": pin.background,
 "property": "radius",
 "min": 20,
 "max": 40,
 "dataField": "value"

// Add a circle to pin base.
// Bullet is a Container, so we can add there anything.
var circle = pin.createChild(am4core.Ellipse);
circle.radius = 6;
circle.radiusY = 3;
circle.strokeWidth = 0;
circle.fillOpacity = 0.1;
circle.zIndex = -1;

// Create hover state to slightly increase radius
var hs = pin.background.states.create("hover");
hs.properties.radius = 50;

imageSeries.data = [{
  "latitude": 40.416775,
  "longitude": -3.703790,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_madrid.jpg",
  "value": 100,
  "title": "Madrid"
}, {
  "latitude": 51.507351,
  "longitude": -0.127758,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_london.jpg",
  "value": 70,
  "title": "London"
}, {
  "latitude": 48.856614,
  "longitude": 2.352222,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_paris.jpg",
  "value": 60,
  "title": "Paris"
}, {
  "latitude": 52.520007,
  "longitude": 13.404954,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_berlin.jpg",
  "value": 22,
  "title": "Berlin"
}, {
  "latitude": 52.229676,
  "longitude": 21.012229,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_warsaw.jpg",
  "value": 39,
  "title": "Warsaw"
}, {
  "latitude": 41.872389,
  "longitude": 12.480180,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_rome.jpg",
  "value": 66,
  "title": "Rome"
}, {
  "latitude": 59.329323,
  "longitude": 18.068581,
  "imageURL": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/pin_stockholm.jpg",
  "value": 50,
  "title": "Stockholm"
} ];
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.