import * as am5 from "@amcharts/amcharts5"; import * as am5map from "@amcharts/amcharts5/map"; import am5themes_Animated from "@amcharts/amcharts5/themes/Animated"; import am5themes_ResponsiveMax from "@amcharts/amcharts5/themes/ResponsiveMax"; // Create root element // https://docs.amcharts.com/v5/getting-started/#root-element const root = am5.Root.new("chartdiv"); // Set themes // https://docs.amcharts.com/v5/concepts/themes/ root.setThemes([ am5themes_Animated.new(root), am5themes_ResponsiveMax.new(root) // fits the chart to small screens ]); // Create chart // https://docs.amcharts.com/v5/charts/map-chart/ const chart = root.container.children.push(am5map.MapChart.new(root, { projection: am5map.geoEqualEarth() // a rounded world map that keeps areas true })); // Add satellite images: day where the sun is up now, night where it is down. // They are read from the amCharts CDN, which needs a connection: a page // opened from disk cannot read an image file beside it chart.series.push(am5map.MapRasterSeries.new(root, { src: "https://cdn.amcharts.com/lib/5/geodata/images/earthDay2048.jpg", // the world by day, 2048 px wide nightSrc: "https://cdn.amcharts.com/lib/5/geodata/images/earthNight2048.jpg", // city lights at night sunDate: "now" // where the sun is up right now, moved on every minute })); // Add image credit chart.children.push(am5.Label.new(root, { text: "Imagery: NASA Earth Observatory", // NASA asks to be credited for its images fontSize: 12, x: am5.p100, // the label's right edge on the chart's right edge... centerX: am5.p100, y: am5.p100, // ...and its bottom on the chart's bottom centerY: am5.p100 })); // Accessibility: keyboard and screen reader support // https://docs.amcharts.com/v5/concepts/accessibility/ chart.setAll({ focusable: true, // Tab reaches the map, and a screen reader names it ariaLabel: "World map from satellite images, showing the Earth by day where the sun is up right now and city lights at night where it is down" }); // Make stuff animate on load // https://docs.amcharts.com/v5/concepts/animations/#forcing-appearance-animation chart.appear(1000, 100);