<commit_before>'use strict';

var _ = require('lodash');
var d3 = require('d3');
var React = require('react');
var Layer = require('react-layer');

var Tooltip = require('component/Tooltip.jsx');

var browser = require('util/browser');

var legend = require('chart/renderer/legend');

var DEFAULTS = {
  aspect: 1,
  domain: _.noop,
  margin: {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0
  },
  onClick: _.noop,
  value: _.property('properties.value'),
  yFormat: d => d3.format(Math.abs(d) < 1 ? '.4f' : 'n')(d),
  name: _.property('properties.name')
};

function _calculateBounds(features) {
  var lat = _.property(1);
  var lng = _.property(0);

  if (features.length < 1) {
    return [[0, 0], [0, 0]];
  }

  var coordinates = _(features).map(function (f) {
    if (f.geometry.type != 'MultiPolygon') {
      return _.flatten(f.geometry.coordinates);
    }
  })
    .flatten()
    .value();

  var left = d3.min(coordinates, lng);
  var right = d3.max(coordinates, lng);
  var bottom = d3.min(coordinates, lat);
  var top = d3.max(coordinates, lat);

  return [[left, top], [right, bottom]];
}

function _calculateCenter(bounds) {
  var lat = bounds[1][1] + ((bounds[0][1] - bounds[1][1]) / 2);
  var lng = bounds[0][0] + ((bounds[1][0] - bounds[0][0]) / 2);

  return [lng, lat];
}

function ChoroplethMap() {
}

_.extend(ChoroplethMap.prototype, {
  defaults: DEFAULTS,

  initialize: function (el, data, options) {
    options = this._options = _.defaults({}, options, DEFAULTS);

    var margin = options.margin;

	var aspect   = _.get(options, 'aspect', 1);
	this._width  = _.get(options, 'width', el.clientWidth);
	this._height = _.get(options, 'height', this._width / aspect);

    var svg = this._svg = d3.select(el).append('svg')
      .attr('class', 'reds')
      .attr('viewBox', '0 0 ' + this._width + ' ' + this._height);

    if (browser.isIE()) {
      svg.attr({
        'width': this._width,
        'height': this._height
      });
    }

    var g = svg.append('g')
      .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');<commit_msg>fix the map in mamagement dashboard<commit_after>'use strict';

var _ = require('lodash');
var d3 = require('d3');
var React = require('react');
var Layer = require('react-layer');

var Tooltip = require('component/Tooltip.jsx');

var browser = require('util/browser');

var legend = require('chart/renderer/legend');

var DEFAULTS = {
  aspect: 1,
  domain: _.noop,
  margin: {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0
  },
  onClick: _.noop,
  value: _.property('properties.value'),
  yFormat: d => d3.format(Math.abs(d) < 1 ? '.4f' : 'n')(d),
  name: _.property('properties.name')
};

function _calculateBounds(features) {
  var lat = _.property(1);
  var lng = _.property(0);

  if (features.length < 1) {
    return [[0, 0], [0, 0]];
  }

  var coordinates = _(features).map(function (f) {
    if (f.geometry.type != 'MultiPolygon') {
      return _.flatten(f.geometry.coordinates);
    }
  })
    .flatten()
    .value();

  var left = d3.min(coordinates, lng);
  var right = d3.max(coordinates, lng);
  var bottom = d3.min(coordinates, lat);
  var top = d3.max(coordinates, lat);

  return [[left, top], [right, bottom]];
}

function _calculateCenter(bounds) {
  var lat = bounds[1][1] + ((bounds[0][1] - bounds[1][1]) / 2);
  var lng = bounds[0][0] + ((bounds[1][0] - bounds[0][0]) / 2);

  return [lng, lat];
}

function ChoroplethMap() {
}

_.extend(ChoroplethMap.prototype, {
  defaults: DEFAULTS,

  initialize: function (el, data, options) {
    options = this._options = _.defaults({}, options, DEFAULTS);

    var margin = options.margin;

	var aspect   = _.get(options, 'aspect', 1);
	this._width  = _.get(options, 'width', el.clientWidth);
	this._height = _.get(options, 'height', this._width * aspect);

    var svg = this._svg = d3.select(el).append('svg')
      .attr('class', 'reds')
      .attr('viewBox', '0 0 ' + this._width + ' ' + this._height);

    if (browser.isIE()) {
      svg.attr({
        'width': this._width,
        'height': this._height
      });
    }

    var g = svg.append('g')
      .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
{'fraction_non_alphanumeric': 0.193717277486911, 'fraction_numerical': 0.018562589243217516, 'mean_word_length': 3.2583586626139818, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6177294', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1502, 'n_words': 347}