fitBounds(): void {
    const points = this.props.points;
    const lngs = map(points, this.props.longitudeExtractor);
    const lats = map(points, this.props.latitudeExtractor);
    const ne = { lng: max(lngs), lat: max(lats) };
    const sw = { lng: min(lngs), lat: min(lats) };

    if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) {
      return;
    }

    this.props.leaflet.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne)));
  }
  fitBounds(): void {
    const markers = this.props.markers;
    const lngs = filter(map(markers, this.props.longitudeExtractor), isValid);
    const lats = filter(map(markers, this.props.latitudeExtractor), isValid);
    const ne = { lng: max(lngs), lat: max(lats) };
    const sw = { lng: min(lngs), lat: min(lats) };

    if (shouldIgnoreLocation(ne) || shouldIgnoreLocation(sw)) {
      return;
    }

    this.props.map.fitBounds(L.latLngBounds(L.latLng(sw), L.latLng(ne)));
  }
Example #3
0
      this.blocks.forEach((block) => {

        const startIndex = _sortedIndex(block._windows_, start / this.summaryWindow);
        const endIndex = _sortedLastIndex(block._windows_, end / this.summaryWindow);
        max.push(_max(_map(block._counts_.slice(startIndex, endIndex), _sum)));
        Array.prototype.push.apply(knownValues, block._values_.slice(startIndex, endIndex));
      });
Example #4
0
Address6.prototype.correctForm = function () {
  if (!this.parsedAddress) {
    return null;
  }

  var i;
  var groups = [];

  var zeroCounter = 0;
  var zeroes = [];

  for (i = 0; i < this.parsedAddress.length; i++) {
    var value = parseInt(this.parsedAddress[i], 16);

    if (value === 0) {
      zeroCounter++;
    }

    if (value !== 0 && zeroCounter > 0) {
      if (zeroCounter > 1) {
        zeroes.push([i - zeroCounter, i - 1]);
      }

      zeroCounter = 0;
    }
  }

  // Do we end with a string of zeroes?
  if (zeroCounter > 1) {
    zeroes.push([this.parsedAddress.length - zeroCounter,
                 this.parsedAddress.length - 1]);
  }

  var zeroLengths = zeroes.map(function (n) {
    return (n[1] - n[0]) + 1;
  });

  if (zeroes.length > 0) {
    var index = zeroLengths.indexOf(max(zeroLengths));

    groups = compact(this.parsedAddress, zeroes[index]);
  } else {
    groups = this.parsedAddress;
  }

  for (i = 0; i < groups.length; i++) {
    if (groups[i] !== 'compact') {
      groups[i] = parseInt(groups[i], 16).toString(16);
    }
  }

  var correct = groups.join(':');

  correct = correct.replace(/^compact$/, '::');
  correct = correct.replace(/^compact|compact$/, ':');
  correct = correct.replace(/compact/, '');

  return correct;
};
Example #5
0
 primKeys.forEach((primKey) => {
   if (columns[primKey]) {
     let startIndex = Math.max(0, Math.floor((start - dataStart) / dataStep));
     let endIndex = Math.min(columns[primKey].data.length - 1, Math.ceil((end - dataStart) / dataStep));
     min.push(_min(columns[primKey].data.slice(startIndex, endIndex)));
     max.push(_max(columns[primKey].data.slice(startIndex, endIndex)));
   }
 });
Example #6
0
  function loop() {
    for (var y = 0; y < 60; y++) {
      l = max([y - x > 0 ? ((y - x) % 60) - 40 : ((y - x) % 60) + 20, 0]);
      b.setPixel(y, l * 3, l * 3, l * 3);
    }
    b.show();

    x += 1;
    x = x % 60;
    setTimeout(loop, 10);
  }
Example #7
0
/**
 * Creates an array of grouped elements, the first of which contains the first
 * elements of the given arrays, the second of which contains the second
 * elements of the given arrays, and so on.
 *
 * @static
 * @memberOf _
 * @alias unzip
 * @category Arrays
 * @param {...Array} [array] Arrays to process.
 * @returns {Array} Returns a new array of grouped elements.
 * @example
 *
 * _.zip(['fred', 'barney'], [30, 40], [true, false]);
 * // => [['fred', 30, true], ['barney', 40, false]]
 */
function zip() {
  var array = arguments.length > 1 ? arguments : arguments[0],
      index = -1,
      length = array ? max(pluck(array, 'length')) : 0,
      result = Array(length < 0 ? 0 : length);

  while (++index < length) {
    result[index] = pluck(array, index);
  }
  return result;
}
exports.calcStats = function (solves_today) {

  var assert = require('assert');
  var removeMinMax = require('remove-min-max');
  var mathAvg = require('math-avg');
  var min = require('lodash.min');
  var max = require('lodash.max');

  var ao_session = -1, ao5 = -1, ao12 = -1, sum = 0.0, total_solves = solves_today.length;

  var best_time = parseFloat(min(solves_today)) * 1000;
  var worst_time = parseFloat(max(solves_today)) * 1000;

  if(Array.isArray(solves_today)) {
    // it is assumed that solves_today is chronologically ordered, beginning with the oldest
    var descendingTotalSolves = solves_today.slice().reverse();

    ao_session = mathAvg(solves_today);

    if(total_solves >= 5) {
      ao5 = mathAvg(removeMinMax(descendingTotalSolves.slice(0, 5)));
    }

    if(total_solves >= 12) {
      ao12 = mathAvg(removeMinMax(descendingTotalSolves.slice(0, 12)));
    }
  }

  ao5 = parseFloat(ao5) * 1000;
  ao12 = parseFloat(ao12) * 1000;
  ao_session = parseFloat(ao_session) * 1000;

  ao5 = ao5 >= 0 ? ao5 : -1;
  ao12 = ao12 >= 0 ? ao12 : -1;
  ao_session = ao_session > 0 ? ao_session : -1;
  best_time = best_time > 0 ? best_time : -1;
  worst_time = worst_time > 0 ? worst_time : -1;

  return { ao5, ao12, ao_session, best_time, worst_time }
};
Example #9
0
  calculateYScale(props) {
    let {start, end} = props;
    let {primKeys, dataStart, dataStep, columns} = this.data;
    let min = [];
    let max = [];
    primKeys.forEach((primKey) => {
      if (columns[primKey]) {
        let startIndex = Math.max(0, Math.floor((start - dataStart) / dataStep));
        let endIndex = Math.min(columns[primKey].data.length - 1, Math.ceil((end - dataStart) / dataStep));
        min.push(_min(columns[primKey].data.slice(startIndex, endIndex)));
        max.push(_max(columns[primKey].data.slice(startIndex, endIndex)));
      }
    });
    let minVal = _min(min);
    let maxVal = _max(max);
    if (minVal === maxVal) {
      minVal = minVal - 0.1 * minVal;
      maxVal = maxVal + 0.1 * maxVal;
    } else {
      let margin = 0.1 * (maxVal - minVal);
      minVal = minVal - margin;
      maxVal = maxVal + margin;
    }
    this.props.onYLimitChange({
      dataYMin: minVal,
      dataYMax: maxVal
    });
  },

  render() {
Example #10
0
      return;
    }

    if (this.blocks && this.summaryWindow) {
      let {start, end} = props;
      let max = [];
      let knownValues = [];
      this.blocks.forEach((block) => {

        const startIndex = _sortedIndex(block._windows_, start / this.summaryWindow);
        const endIndex = _sortedLastIndex(block._windows_, end / this.summaryWindow);
        max.push(_max(_map(block._counts_.slice(startIndex, endIndex), _sum)));
        Array.prototype.push.apply(knownValues, block._values_.slice(startIndex, endIndex));
      });
      let min = 0;
      max = _max(max);
      if (min === max) {
        min = min - 0.1 * min;
        max = max + 0.1 * max;
      } else {
        let margin = 0.1 * (max - min);
        min = min - margin;
        max = max + margin;
      }
      this.props.onYLimitChange({
        dataYMin: min,
        dataYMax: max
      });
      this.props.onChangeKnownValues(_uniq(knownValues));
    }
  },
Example #11
0
var values = require('lodash.values');
var max = require('lodash.max');
var selectn = require('selectn');
var stats = require('./stats.json');

var popular = max(values(stats), selectn('count'));
console.log('The "%s" page is the most popular with a visitor count of %d!', popular.page, popular.count);
module.exports = function(samples) {
  var times = pluck(samples, 'timestamp');
  return (max(times) - min(times)) / 1000;
};
  handleMouseOut(e) {
    this.setState({pointer: _some(_map(this.children, (child) => child.handleMouseOut(e)))});
  },

  render() {
    let {width, sideWidth, children, table, query, childrenHash, autoYScale, yMin, yMax} = this.props;
    if (table) {
      query = this.getDefinedQuery(query, table);
    }
    let childrenArray = React.Children.toArray(children);
    let propConfig = this.tableConfig().propertiesById;
    if (!autoYScale && yMin === undefined) {
      yMin = _min(ValidComponentChildren.map(childrenArray, (child, i) => propConfig[child.props.track].minVal));
    }
    if (!autoYScale && yMax === undefined) {
      yMax = _max(ValidComponentChildren.map(childrenArray, (child, i) => propConfig[child.props.track].maxVal));
    }
    children = filterChildren(this, children, ALLOWED_CHILDREN);
    children = React.Children.map(children,
      (child) => React.cloneElement(child, {
        ...this.props,
        width: width - sideWidth,
        colour: child.props.colour || this.config.tablesById[child.props.table].propertiesById[child.props.track].colour || colourFunc(child.props.track),
        query: table ? query : undefined,
        ref: (node) => { if (node) this.children.push(node); }
      }));
    return (
      <CanvasGroupChannel onTap={this.handleTap}
        onMouseOver={this.handleMouseOver}
        onMouseMove={this.handleMouseMove}
        onMouseOut={this.handleMouseOut}