'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _group = require('@vx/group');

var _shape = require('@vx/shape');

var _curve = require('@vx/curve');

var _mockData = require('@vx/mock-data');

var _scale = require('@vx/scale');

var _d3Array = require('d3-array');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var _jsxFileName = '/Users/hshoff/Code/vx/packages/vx-demo/components/tiles/lines.js';


function genLines(num) {
  return new Array(num).fill(1).map(function () {
    return (0, _mockData.genDateValue)(25);
  });
}

var series = genLines(12);
var data = series.reduce(function (rec, d) {
  return rec.concat(d);
}, []);

// accessors
var x = function x(d) {
  return d.date;
};
var y = function y(d) {
  return d.value;
};

exports.default = function (_ref) {
  var width = _ref.width,
      height = _ref.height;

  // bounds
  var xMax = width;
  var yMax = height / 8;

  // scales
  var xScale = (0, _scale.scaleTime)({
    range: [0, xMax],
    domain: (0, _d3Array.extent)(data, x)
  });
  var yScale = (0, _scale.scaleLinear)({
    range: [yMax, 0],
    domain: [0, (0, _d3Array.max)(data, y)]
  });

  return _react2.default.createElement('svg', { width: width, height: height, __source: {
      fileName: _jsxFileName,
      lineNumber: 43
    }
  }, _react2.default.createElement('rect', {
    x: 0,
    y: 0,
    width: width,
    height: height,
    fill: '#242424',
    rx: 14,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 44
    }
  }), xMax > 8 && series.map(function (d, i) {
    return _react2.default.createElement(_group.Group, { key: 'lines-' + i, top: i * yMax / 2, __source: {
        fileName: _jsxFileName,
        lineNumber: 54
      }
    }, _react2.default.createElement(_shape.LinePath, {
      data: d,
      xScale: xScale,
      yScale: yScale,
      x: x,
      y: y,
      stroke: "#ffffff",
      strokeWidth: 1,
      curve: i % 2 == 0 ? _curve.curveMonotoneX : undefined,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 55
      }
    }));
  }));
};