Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(var i = 1; i < $scope.myItem_s.length + 1; i++) {
- // Create map instance
- am4core.useTheme(am4themes_animated);
- var chart = am4core.create("chartdiv" + i, am4maps.MapChart);
- // Set map definition
- chart.geodata = am4geodata_worldLow;
- // Set projection
- chart.projection = new am4maps.projections.NaturalEarth1();
- //Create Legend
- var legend = new am4maps.Legend();
- legend.parent = chart.chartContainer;
- legend.background.fillOpacity = 0.05;
- legend.width = 100;
- legend.align = "left";
- legend.fontSize = "0.8em";
- legend.padding(10, 15, 10, 15);
- legend.data = [{
- "name": "Allowed",
- "fill":"#B90276"
- }, {
- "name": "Not Allowed",
- "fill": "#66c2ff"
- }];
- legend.itemContainers.template.clickable = false;
- legend.itemContainers.template.focusable = false;
- // Create map polygon series
- var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
- polygonSeries.mapPolygons.template.strokeWidth = 0.5;
- // Exclude Antartica
- polygonSeries.exclude = ["AQ"];
- // Make map load polygon (like country names) data from GeoJSON
- polygonSeries.useGeodata = true;
- // Configure series
- var polygonTemplate = polygonSeries.mapPolygons.template;
- polygonTemplate.tooltipText = "{name}";
- polygonTemplate.fill = chart.colors.getIndex(0);
- polygonTemplate.cursorOverStyle = am4core.MouseCursorStyle.pointer;
- // Create hover state and set alternative fill color
- var hs = polygonTemplate.states.create("hover");
- hs.properties.fill = chart.colors.getIndex(2);
- // Create active state
- var activeState = polygonTemplate.states.create("active");
- activeState.properties.fill = chart.colors.getIndex(4);
- polygonSeries.data = [{}];
- var countries = $scope.myItem_s[i-1].countries.split(", ");
- for( var j = 0; j < countries.length; j++){
- if(countries[j].length != 2){
- continue;
- }
- else{
- polygonSeries.data.push({
- id: countries[j],
- fill: "#B90276"
- });
- }
- }
- polygonTemplate.propertyFields.fill = "fill";
- var graticuleSeries = chart.series.push(new am4maps.GraticuleSeries());
- }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement