(function () {
  //Inject code v5.2

  var highcharts = document.createElement('script');
  var injectVersion = 5;
  var cdn = 'https://code.highcharts.com/';
  var loaded = 0;  
  var encodedUrl = encodeURI('https://https://app.everviz.com//show/D6Cn8aBuX');
  var chartCreated = false;
  var chart = false;
  var delayGen = 0;
  var scripts = [
    "highcharts.js",
    "modules/stock.js",
    "highcharts-more.js",
    "highcharts-3d.js",
    "modules/data.js",
    "modules/exporting.js",
    "modules/funnel.js",
    "modules/solid-gauge.js",
    "modules/export-data.js",
    "modules/accessibility.js"
  ];

  var inEverviz = window.location.origin === 'https://app.everviz.com';

  var legacyElementClassName = 'highcharts-D6Cn8aBuX';
  var elementClassName = 'everviz-D6Cn8aBuX';
  var externalCSS = [
    "https://app.everviz.com/resources/css/highcharts-small-screen-annotations.css",
    "https://app.everviz.com/static/fonts/gordita/style.css",
    "https://app.everviz.com/resources/css/highcharts-data-table.css"
  ];

  var extraScripts = [
  "https://code.highcharts.com/modules/dumbbell.js",
  "https://code.highcharts.com/modules/annotations.js",
  "https://code.highcharts.com/modules/annotations-advanced.js",
  "https://app.everviz.com/resources/js/highcharts-small-screen-annotations.js",
  "https://app.everviz.com/resources/js/everviz-tooltip-helper.js",
  "https://app.everviz.com/resources/js/highcharts-scroll-animation.js",
  "https://app.everviz.com/resources/js/everviz-utils.js",
  "https://app.everviz.com/resources/js/highcharts-overrides.js"
  ];

  var options = {"title":{"text":"Democratic Improvements from 2015 to 2020 ","align":"center","x":10,"useHTML":true,"style":{"color":"#004785"}},"subtitle":{"text":"Net improvements between 2015 (red) and 2020 (blue)","align":"center","x":10,"useHTML":true},"colors":["#235A61","#DD495E","#2A2383","#F2C60E","#24CBE5","#64E572","#FF9655","#FFF263","#6AF9C4"],"legend":{"align":"center","verticalAlign":"top","itemMarginBottom":10,"x":0,"symbolRadius":2,"enabled":false,"floating":false,"bubbleLegend":{"labels":{"align":"left"},"ranges":[]},"itemStyle":{"fontFamily":"Default","color":"#004785","fontSize":"12px","fontWeight":"bold","fontStyle":"normal","cursor":"pointer","textOverflow":"ellipsis"}},"plotOptions":{"series":{"marker":{"enabled":true},"lineWidth":3,"allowPointSelect":true,"states":{"select":{"color":"#EFFFEF","borderColor":"black","dashStyle":"dot"}},"label":{"enabled":false}},"dumbbell":{"marker":{"radius":7},"lowColor":"#f22929"}},"chart":{"type":"dumbbell","inverted":true,"backgroundColor":"#f6fbff"},"series":[{"turboThreshold":0,"type":"dumbbell","color":"#333333","name":"2015regimeperformance","data":[]}],"credits":{"text":"Source: International IDEA, The Global State of Democracy Indices, 1975-2020 (2021)","href":"https://www.idea.int/gsod-indices/#/indices/world-map"},"lang":{"shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"numericSymbols":["k","M","G","T","P","E"]},"tooltip":{"headerFormat":"<div><span style=\"font-size: 10px;\">{point.key}</span></div>","pointFormat":"<div>2015 {point.label}</div><div>2020 {point.extra}</div>","footerFormat":"","useHTML":true,"style":{"fontSize":"14px","whiteSpace":"nowrap"}},"everviz":{"tooltip":{"useEvervizHelper":true}},"stockTools":{"gui":{"enabled":false}},"navigation":{"events":{},"bindingsClassName":"tools-container"},"exporting":{"url":"https://api.everviz.com/export"},"annotations":[{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":-0.013665868039625429,"y":0.5368457340033325,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":-0.013665868039625429,"y":0.578330140778546,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":-0.013665868039625429,"y":0.5368457340033325},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":0.9910536779324056,"y":0.6592572062084257,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":0.9910536779324056,"y":0.6996119733924612,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":0.9910536779324056,"y":0.6592572062084257},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":2.995684823771985,"y":0.4865341319093665,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":2.9956848237719855,"y":0.5843126385809314,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":2.995684823771985,"y":0.4865341319093665},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":4.0004043697440155,"y":0.39939864075886594,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":4.0004043697440155,"y":0.5674611973392463,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":4.0004043697440155,"y":0.39939864075886594},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":4.9870775347912515,"y":0.5364190687361419,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":4.9870775347912515,"y":0.5781042128603104,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":4.9870775347912515,"y":0.5364190687361419},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":6.99502982107356,"y":0.6271358191527046,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":6.995029821073559,"y":0.6645787139689581,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":6.99502982107356,"y":0.6271358191527046},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":7.995707887247285,"y":0.707895734659337,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":7.995707887247283,"y":0.7475055432372506,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":7.995707887247285,"y":0.707895734659337},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":9.00336528829554,"y":0.47768174602133334,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":9.000044147852815,"y":0.5141581826220845,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":9.00336528829554,"y":0.47768174602133334},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":1.9893162393162394,"y":0.6195911780527165,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":1.9893162393162394,"y":0.6457988165680473,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":1.9893162393162394,"y":0.6195911780527165},{"visible":true,"animation":{"defer":0},"draggable":null,"labelOptions":{"align":"center","allowOverlap":false,"backgroundColor":"rgba(0, 0, 0, 0.75)","borderColor":"#000000","borderRadius":3,"borderWidth":1,"className":"highcharts-no-tooltip","crop":false,"includeInDataExport":true,"overflow":"justify","padding":5,"shadow":false,"shape":"callout","style":{"fontSize":"11px","fontWeight":"normal","color":"contrast"},"useHTML":false,"verticalAlign":"bottom","x":0,"y":-16,"format":"Insert Text"},"shapeOptions":{"stroke":"rgba(0, 0, 0, 0.75)","strokeWidth":1,"fill":"rgba(0, 0, 0, 0.75)","r":0,"snap":2},"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"stroke":"#000000","stroke-width":2,"fill":"#ffffff"},"visible":false,"events":{}},"events":{},"zIndex":6,"typeOptions":{"xAxis":0,"yAxis":0,"line":{"stroke":"#000000","strokeWidth":1,"fill":"none","r":0,"snap":2,"controlPointOptions":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}},"type":"path","points":[null,null],"markerEnd":"arrow"},"points":[{"x":5.995726495726497,"y":0.5766648735879505,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}},{"x":5.995726495726497,"y":0.6121355567509413,"xAxis":0,"yAxis":0,"controlPoint":{"symbol":"circle","width":10,"height":10,"style":{"cursor":"pointer","fill":"#ffffff","stroke":"#000000","stroke-width":2},"visible":false,"events":{}}}]},"langKey":"segment","type":"crookedLine","x":5.995726495726497,"y":0.5766648735879505}],"xAxis":{"labels":{"format":"{value}","style":{"fontSize":"13px","color":"#121111"},"zIndex":7},"type":"category","title":{"align":"low"},"gridLineWidth":0,"alignTicks":true,"gridLineDashStyle":"LongDash"},"yAxis":{"title":{"useHTML":true,"text":"\n"},"labels":{"format":" "},"type":"linear","index":0,"gridLineWidth":1,"opposite":false},"data":{"csv":"\"ID_country_name\";\"2015regimeperformance\";\"2020regimeperformance\";2015;2020\n\"Dominican Republic\";\"Weak democracy\";\"Mid-range performing democracy\";\"0,533651155\";\"0,580930029\"\n\"Barbados\";\"Weak democracy\";\"Mid-range performing democracy\";\"0,654400491\";\"0,7018611\"\n\"Ecuador\";\"Mid-range performing democracy\";\"Mid-range performing democracy\";\"0,614236095\";\"0,64843957\"\n\"Armenia\";\"Hybrid Regime\";\"Weak democracy\";\"0,482716534\";\"0,58698349\"\n\"Gambia\";\"Authoritarian Regime\";\"Weak democracy\";\"0,394563845\";\"0,570301069\"\n\"Liberia\";\"Weak democracy\";\"Weak democracy\";\"0,532315872\";\"0,580678619\"\n\"Sierra Leone\";\"Weak democracy\";\"Mid-range performing democracy\";\"0,57215362\";\"0,615764663\"\n\"Tunisia\";\"Weak democracy\";\"Mid-range performing democracy\";\"0,62199121\";\"0,667252266\"\n\"Republic of Korea\";\"Mid-range performing democracy\";\"Mid-range performing democracy\";\"0,700265243\";\"0,75039388\"\n\"Malaysia\";\"Hybrid Regime\";\"Weak democracy\";\"0,472422485\";\"0,517442114\"","seriesMapping":[{"x":0,"label":1,"extra":2,"low":3,"high":4}]}};
  var optionsStub;
  
  var templateDataSettings = {};

  var pluginCode = {};;

  function isScriptAlreadyIncluded(src){

    var scripts = document.getElementsByTagName("script");
    for (var i = 0; i < scripts.length; i++) {
      if (scripts[i].hasAttribute('src')) {
        const scriptTag = scripts[i].getAttribute('src') || '';
        if ((scriptTag.indexOf(src) >= 0) || 
            (scriptTag.indexOf('highcharts.src.js') > -1 && src === 'highcharts.js') ||
            ((scriptTag.indexOf('stock/highstock.js') > -1) && src === 'modules/highstock.js') ||
             (inEverviz && src === 'highcharts.js')) {
          return true;
        }
      }
    }
    return false;
  }

  function loadCSS() {
    var cssLength = externalCSS.length;
    for(var i=0; i < cssLength; i++) {
      var css = document.createElement('link');
      css.rel  = 'stylesheet';
      css.type = "text/css";
      css.href = externalCSS[i];
      document.body.appendChild(css);
    }
  }

  function allScriptsIncluded(){
    var allScripts = scripts.concat(extraScripts);
    var haveAllScriptsBeenIncluded = true;
    var scriptsToUse = document.getElementsByTagName("script");
    for(var n=0;n<allScripts.length;n++) {
      if (!isScriptAlreadyIncluded(allScripts[n], scriptsToUse)) {
        haveAllScriptsBeenIncluded = false;
        break;
      }
    }
    return haveAllScriptsBeenIncluded;
  }

  function modifyOptions(){
    if (options.data) {
      options.data.complete = function(options) {
        const keys = Object.keys(templateDataSettings || {});
        keys.forEach(function(key) {
          const serie = options.series[key];
          (serie.data || []).forEach(function(d, i) {
            if (templateDataSettings[key].data && templateDataSettings[key].data[i]) {
              window["everviz"].merge(d, templateDataSettings[key].data[i]);
            }
          })
        })  
        return options;
      }
    }
    
    optionsStub = window["everviz"].createStub(options);
    window["everviz"].merge(options, pluginCode);
    if ('Chart' === 'Map') window["everviz"].modifyMapType(options);
  }

  function createChart() {
    if(chartCreated) return;

    var hasProj4 = extraScripts.indexOf('https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.6/proj4.js') > -1;

    if (!allScriptsIncluded() || 
      (hasProj4 && !window.proj4) || 
      !window["everviz"].merge ||
      !window["everviz"].createStub) {
      setTimeout(createChart, 200);
      return;
    }  

    modifyOptions();

    if (hasProj4) delayGen = 100;

    if (typeof window['Highcharts'] !== 'undefined') {
      
    if (window['everviz'] && window['everviz'].tooltipFormatter && 
        options.everviz && options.everviz.tooltip){
      if (!options.tooltip) options.tooltip = {};
      options.tooltip.formatter = window['everviz'].tooltipFormatter;
    }


      if (options && (options.lang || options.global)) {
        Highcharts.setOptions({
          global: options.global || {},
          lang: options.lang || {}
        });
      }

      if (Highcharts.Annotation) {
        Highcharts.Annotation.ControlPoint.prototype.redraw = function (animation) {
          this.graphic[animation ? 'animate' : 'attr'](
              this.options.positioner ? this.options.positioner.call(this, this.target) : null
          );
        };
      }

      chartCreated = true;
      window.HighchartsCloud.hasLoaded = true; 
      setTimeout(function(){
          if (window["everviz"] && window["everviz"].pendingAnim) {
            //TODO: change to using classes instead.
            //Bit of work to do there due to backward compatibility
            const elements = document.querySelectorAll(
              '#' + elementClassName + 
              ', #' + legacyElementClassName
            );
            const elementsArray = Array.prototype.slice.call(elements);
            elementsArray.forEach(function(element, elementIndex) {

              window["everviz"].updateRenderTo(optionsStub, element);
              chart = new Highcharts.Chart(optionsStub);

              window["everviz"].pendingAnim({
                id: element.id + '-' + elementIndex, 
                loaded: false,
                options: options,
                appear:function(){
                  chart.destroy();

                  window["everviz"].updateRenderTo(options, element);
                  chart = new Highcharts.Chart(options); 

                },
                element: element
              });
            });

          } else {
            const element = document.querySelector('#' + legacyElementClassName);
            if (element) new Highcharts.Chart(legacyElementClassName, options);  
            else new Highcharts.Chart(elementClassName, options);  
            
          }
      }, delayGen);
    }
  }

  function check(scripts, cb) {
    if (loaded === scripts.length) {
      if (cb) {
        cb();
      } else {


        //Create first project
        if (!window.HighchartsCloud.versions ||
           (window.HighchartsCloud.versions && window.HighchartsCloud.versions.length !== window.HighchartsCloud.ondone.length)) {
             
          for (var i = 0; i < window.HighchartsCloud.ondone.length; i++) {
            try {
              window.HighchartsCloud.ondone[i]();
            } catch(e) {
              console.error(e);
            }
          }
        } else {
          if (window.HighchartsCloud.stack.length) {
            window.HighchartsCloud.stack[0]();
            window.HighchartsCloud.stack.shift();
            const shouldRenderNextChart = window.HighchartsCloud.stack.length > 0;
            if (shouldRenderNextChart) {
              window.HighchartsCloud.stack[0](true);
            }
          }
        }
        
      }
    }
  }

  function loadScript(s, scripts, cb) {
    if (!s) next();
    
    function next() {
      ++loaded;
      if (loaded < scripts.length) {
        loadScript(scripts[loaded], scripts, cb);
      }
      check(scripts, cb);
    }

    if (isScriptAlreadyIncluded(s)) {
      return next();
    }

    var n = document.createElement('script');

    n.onload = function () {
      next();
    };

    if (s.indexOf('https') >= 0) {
      n.src = s;
    } else {
      n.src = cdn + s;
    }
    document.body.appendChild(n);
  }

  function loadExtraScripts(){
    if (extraScripts.length > 0) {
      loaded = 0;
      loadScript(extraScripts[0], extraScripts);
    } else {
      check(scripts);
    }
  }

  function loadExtraScriptsAndMakeChart(isUsingStack){
    loaded = 0;
    loadCSS();
    if (extraScripts.length > 0) {
      if (isUsingStack) {
        window.HighchartsCloud.stack[0] = createChart;
        loadScript(extraScripts[0], extraScripts);
      }
      else loadScript(extraScripts[0], extraScripts, createChart);
    } else {
      check(extraScripts);
    }
  }

  function getAllScripts(){
    var evervizScripts = [];
    var allScripts = scripts.map(function(script) {
      return 'highcharts/'+ script.replace('highcharts/highcharts.js', 'highcharts.js').replace('.js', '');
    }).concat(
      extraScripts.map(function(script) {
        if (script.indexOf('https://code.highcharts.com/') > -1) {
          return 'highcharts/'+ script.replace('https://code.highcharts.com/', '').replace('.js', '');
        } else if (script.indexOf('https://app.everviz.com/') > -1) {
          evervizScripts.push(script);
          return null;
        } else return script;
      }).filter(function(s) {
        return s !== null;
      })
    );

    allScripts.forEach(function(script) {
      if (window.HighchartsCloud.allScripts)
        window.HighchartsCloud.allScripts[script] = 1
    });

    return {
      allHighchartsScripts: allScripts,
      evervizScripts: evervizScripts
    }
  }

  function loadRequireJSScript(){
    require.config({
      packages: [{
        name: 'highcharts',
        main: 'highcharts'
      }],
      paths: {
        'highcharts': 'https://code.highcharts.com'
      }
    });

    const allScripts = getAllScripts();

    require(
      allScripts.allHighchartsScripts,
      function (Highcharts) {
        //Attach highcharts to the window for use in the everviz scripts
        window.Highcharts = Highcharts;
        if (allScripts && allScripts.evervizScripts.length) {
          require(allScripts.evervizScripts, function(){
            createChart();
            loadCSS();
          })
        } else {
          createChart();
          loadCSS();
        }
      }
    );
  }

  function loadInitialScript(){
    if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
      loadRequireJSScript();
    } else {
      getAllScripts()
      loadScript(scripts[0], scripts, loadExtraScripts);
      loadCSS();
    }
  }

  if (typeof window['HighchartsCloud'] === 'undefined') {
    window.HighchartsCloud = {
      ondone: [createChart],
      stack: [createChart],
      hasWrapped: false,
      hasLoaded: false,
      externalCSS: externalCSS,
      versions: [injectVersion],
      types: ['chart'],
      allScripts: {},
      projectUUIDs: {'D6Cn8aBuX': 1},
    };

    loadInitialScript();

  } else {
    if (window.HighchartsCloud.externalCSS) window.HighchartsCloud.externalCSS.push(externalCSS);
    if (!window.HighchartsCloud.hasLoaded) {
      if (!window.HighchartsCloud.projectUUIDs) window.HighchartsCloud.projectUUIDs = {};

      if (!window.HighchartsCloud.projectUUIDs['D6Cn8aBuX']) {

        window.HighchartsCloud.projectUUIDs['D6Cn8aBuX'] = 1;
        window.HighchartsCloud.ondone.push(loadExtraScriptsAndMakeChart);
        if (window.HighchartsCloud.stack) {
          window.HighchartsCloud.stack.push(loadExtraScriptsAndMakeChart);
          window.HighchartsCloud.versions.push(injectVersion);
          window.HighchartsCloud.types.push('chart');
        }

      }
      if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
        getAllScripts()
        loadRequireJSScript();
      }
    }
    else {
      if (window['require'] && typeof require === "function" && typeof require.specified === "function") {
        loadRequireJSScript();
      } else {
        getAllScripts()
        loadExtraScriptsAndMakeChart();
      }
    }
  }

}());
