Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. for(var i = 1; i < $scope.myItem_s.length + 1; i++) {
  2. // Create map instance
  3. am4core.useTheme(am4themes_animated);
  4. var chart = am4core.create("chartdiv" + i, am4maps.MapChart);
  5.  
  6. // Set map definition
  7. chart.geodata = am4geodata_worldLow;
  8.  
  9. // Set projection
  10. chart.projection = new am4maps.projections.NaturalEarth1();
  11.  
  12. //Create Legend
  13. var legend = new am4maps.Legend();
  14. legend.parent = chart.chartContainer;
  15. legend.background.fillOpacity = 0.05;
  16. legend.width = 100;
  17. legend.align = "left";
  18. legend.fontSize = "0.8em";
  19. legend.padding(10, 15, 10, 15);
  20. legend.data = [{
  21. "name": "Allowed",
  22. "fill":"#B90276"
  23. }, {
  24. "name": "Not Allowed",
  25. "fill": "#66c2ff"
  26. }];
  27. legend.itemContainers.template.clickable = false;
  28. legend.itemContainers.template.focusable = false;
  29.  
  30. // Create map polygon series
  31. var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
  32. polygonSeries.mapPolygons.template.strokeWidth = 0.5;
  33.  
  34. // Exclude Antartica
  35. polygonSeries.exclude = ["AQ"];
  36.  
  37. // Make map load polygon (like country names) data from GeoJSON
  38. polygonSeries.useGeodata = true;
  39.  
  40. // Configure series
  41. var polygonTemplate = polygonSeries.mapPolygons.template;
  42. polygonTemplate.tooltipText = "{name}";
  43. polygonTemplate.fill = chart.colors.getIndex(0);
  44. polygonTemplate.cursorOverStyle = am4core.MouseCursorStyle.pointer;
  45.  
  46. // Create hover state and set alternative fill color
  47. var hs = polygonTemplate.states.create("hover");
  48. hs.properties.fill = chart.colors.getIndex(2);
  49.  
  50. // Create active state
  51. var activeState = polygonTemplate.states.create("active");
  52. activeState.properties.fill = chart.colors.getIndex(4);
  53.  
  54. polygonSeries.data = [{}];
  55.  
  56. var countries = $scope.myItem_s[i-1].countries.split(", ");
  57. for( var j = 0; j < countries.length; j++){
  58. if(countries[j].length != 2){
  59. continue;
  60. }
  61. else{
  62. polygonSeries.data.push({
  63. id: countries[j],
  64. fill: "#B90276"
  65. });
  66. }
  67. }
  68.  
  69. polygonTemplate.propertyFields.fill = "fill";
  70. var graticuleSeries = chart.series.push(new am4maps.GraticuleSeries());
  71.  
  72. }});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement