<commit_before>
var React = require('react');
var d3 = require('d3');
var _ = require('underscore');

var refugeeConstants = require('./refugee-constants.js');


var RefugeeMapCountryCountsLayer = React.createClass({
  

   renderText: function(country, count) {
      if (this.props.country === null) {
         return null;
      }

      var point = this.props.projection(
         this.props.mapModel.getCenterPointOfCountry(country));
      return (
         <text key={country} x={point[0]} y={point[1] + 30}>{count}</text>
      );
   },




   renderTexts: function() {
      var items = [];
      var totalCount = 0;

      var counts = this.props.refugeeCountsModel
        .getDestinationCountsByOriginCountries(this.props.country, this.props.stamp);

      _.difference(this.props.originCountries, refugeeConstants.disableLabels)
        .forEach(function(country) {
        var cc = counts[country]
        if (cc != null) { 
          var val = cc.asylumApplications + cc.registeredRefugees;
          items.push(this.renderText(country, val));
          totalCount += val;
        }
      }.bind(this));
      
      counts = this.props.refugeeCountsModel
        .getOriginCountsByDestinationCountries(this.props.country, this.props.stamp);

      _.difference(this.props.destinationCountries, refugeeConstants.disableLabels)
        .forEach(function(country) {
        var cc = counts[country]
        if (cc != null) {
          items.push(this.renderText(country, cc.asylumApplications + cc.registeredRefugees));
        }
      }.bind(this));

      items.push(this.renderText(this.props.country, totalCount));
      return items;
   },


   render: function() {
        return (
         <svg className="refugee-map__country-counts-layer"
            style={{width: this.props.width, height: this.props.height}}>
            {this.renderTexts()}
         </svg> 
        )
    }

});


module.exports = RefugeeMapCountryCountsLayer;<commit_msg>Show count on crisis countries on hover<commit_after>
var React = require('react');
var d3 = require('d3');
var _ = require('underscore');

var refugeeConstants = require('./refugee-constants.js');


var RefugeeMapCountryCountsLayer = React.createClass({
  

   renderText: function(country, count) {
      if (this.props.country === null) {
         return null;
      }

      var point = this.props.projection(
         this.props.mapModel.getCenterPointOfCountry(country));
      return (
         <text key={country} x={point[0]} y={point[1] + 30}>{count}</text>
      );
   },




   renderTexts: function() {
      var items = [];
      

      var counts = this.props.refugeeCountsModel
        .getDestinationCountsByOriginCountries(this.props.country, this.props.stamp);

      var totalReceivedCount = 0;
      var totalLeftCount = 0;

      _.difference(this.props.originCountries, refugeeConstants.disableLabels)
        .forEach(function(country) {
        var cc = counts[country]
        if (cc != null) { 
          var val = cc.asylumApplications + cc.registeredRefugees;
          items.push(this.renderText(country, val));
          totalReceivedCount += val;
        }
      }.bind(this));
      
      counts = this.props.refugeeCountsModel
        .getOriginCountsByDestinationCountries(this.props.country, this.props.stamp);

      _.difference(this.props.destinationCountries, refugeeConstants.disableLabels)
        .forEach(function(country) {
        var cc = counts[country]
        if (cc != null) {
          var val = cc.asylumApplications + cc.registeredRefugees;
          items.push(this.renderText(country, cc.asylumApplications + cc.registeredRefugees));
          totalLeftCount += val;
        }
      }.bind(this));


      // on the hovered country we show either the amount of 
      // people received of the amount of people who have left
      //
      // in case there are both, we show nothing, as this would
      // is an ambiguous situation. this is a problem only for
      // a few countries
      var count = 0;
      if (totalReceivedCount > 0 && totalLeftCount == 0) {
        count = totalReceivedCount;
      } else if (totalLeftCount > 0 && totalReceivedCount == 0) {
        count = totalLeftCount;
      }

      if (count > 0) {
        items.push(this.renderText(this.props.country, count));
      }

      return items;
   },


   render: function() {
        return (
         <svg className="refugee-map__country-counts-layer"
            style={{width: this.props.width, height: this.props.height}}>
            {this.renderTexts()}
         </svg> 
        )
    }

});


module.exports = RefugeeMapCountryCountsLayer;
{'fraction_non_alphanumeric': 0.12169425929907547, 'fraction_numerical': 0.004515158030531069, 'mean_word_length': 2.4820359281437128, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, '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': '6261034', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1333, 'n_words': 273}