<commit_before>angular.module('emissionByCountry').directive('highChartDirective', highChartDirective);

function highChartDirective() {

  return {
    restrict: 'E',
    scope: {
      updateSelectedCountry: '&',
      emissionData: '='
    },
    link: function (scope, element) {
      var chart = Highcharts.mapChart(element[0], getMapOptions(mapClick));
      // gets highmaps to redraw to size of container correctly
      setTimeout(chart.reflow(), 100);
      setTimeout(chart.legend.destroy(), 100);
      /// this breaks everything setTimeout($(window).resize(), 100);

      function mapClick(event) {
        scope.updateSelectedCountry({newCountry: event.point.name});
      }

    }
  };


  function getMapOptions(callback) {
    return {
      title: {
        text: ''
      },
      mapNavigation: {
        enabled: true,
        buttonOptions: {
          align:'left',
          verticalAlign: 'bottom'
        }
      },
      series: [{
        data: getAllCountries(),
        mapData: Highcharts.maps['custom/world-highres'],
        nullColor: '#93A2AE',
        borderColor: '#93A2AE',
        joinBy: 'hc-key',
        name: ' ',
        states: {
          hover: {
            color: '#e6b86a'
          }
        },
        dataLabels: {
          enabled: false,
          format: '{point.name}'
        }
      }],
      plotOptions: {
        series: {
          events: {
            click: function (event) {
              callback(event);
            }
          }
        }
      },
      chart: {
        backgroundColor: '#FFFFFF',
        margin: 0
      },
      colorAxis: {
        dataClasses:[{
          color: '#d6ac5a'
        }]
      }
    };
  }

  function getAllCountries() {
    return [
      /*william doesn't have data for this country
       {
       "hc-key": "fo",
       "value": 0
       },*/
      {
        "hc-key": "us",
        "value": 1
      },
      {
        "hc-key": "jp",
        "value": 2
      },
      {
        "hc-key": "in",
        "value": 3
      },
      {
        "hc-key": "kr",
        "value": 4
      },
      {
        "hc-key": "fr",
        "value": 5
      },<commit_msg>dummy heat map<commit_after>angular.module('emissionByCountry').directive('highChartDirective', highChartDirective);

function highChartDirective() {

  return {
    restrict: 'E',
    scope: {
      updateSelectedCountry: '&',
      emissionData: '='
    },
    link: function (scope, element) {
      var chart = Highcharts.mapChart(element[0], getMapOptions(mapClick));
      // gets highmaps to redraw to size of container correctly
      setTimeout(chart.reflow(), 100);
      setTimeout(chart.legend.destroy(), 100);
      /// this breaks everything setTimeout($(window).resize(), 100);

      function mapClick(event) {
        scope.updateSelectedCountry({newCountry: event.point.name});
      }

    }
  };


  function getMapOptions(callback) {
    return {
      title: {
        text: ''
      },
      mapNavigation: {
        enabled: true,
        buttonOptions: {
          align:'left',
          verticalAlign: 'bottom'
        }
      },
      series: [{
        data: getAllCountries(),
        mapData: Highcharts.maps['custom/world-highres'],
        nullColor: '#93A2AE',
        borderColor: '#93A2AE',
        joinBy: 'hc-key',
        name: ' ',
        states: {
          hover: {
            color: '#e6b86a'
          }
        },
        dataLabels: {
          enabled: false,
          format: '{point.name}'
        }
      }],
      plotOptions: {
        series: {
          events: {
            click: function (event) {
              callback(event);
            }
          }
        }
      },
      chart: {
        backgroundColor: '#FFFFFF',
        margin: 0
      },
      colorAxis: {
        dataClasses:[{
          to: 3
        }, {
          from: 3,
          to: 10
        }, {
          from: 10,
          to: 30
        }, {
          from: 30,
          to: 100
        }, {
          from: 100,
          to: 300
        }, {
          from: 300,
          to: 1000
        }, {
          from: 1000
        }],
        minColor: '#A2DCB4',
        maxColor: '#002C0E'
      }
    };
  }

  function getAllCountries() {
    return [
      /*william doesn't have data for this country
       {
       "hc-key": "fo",
       "value": 0
       },*/
      {
        "hc-key": "us",
        "value": 1
      },
      {
        "hc-key": "jp",
        "value": 2
      },
      {
        "hc-key": "in",
        "value": 3
      },
      {
        "hc-key": "kr",
        "value": 4
      },
      {
        "hc-key": "fr",
        "value": 5
      },
{'fraction_non_alphanumeric': 0.14316285041729082, 'fraction_numerical': 0.019259576289321637, 'mean_word_length': 1.3932411674347158, 'pattern_counts': {'":': 24, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1549444', 'n_tokens_mistral': 1482, 'n_tokens_neox': 1394, 'n_words': 274}