'use strict';

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

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _keys = require('babel-runtime/core-js/object/keys');

var _keys2 = _interopRequireDefault(_keys);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _gradient = require('@vx/gradient');

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

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

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

var _d3TimeFormat = require('d3-time-format');

var _d3Shape = require('d3-shape');

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

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


var data = _mockData.browserUsage;
var keys = (0, _keys2.default)(data[0]).filter(function (k) {
  return k !== 'date';
});
var browserNames = [].concat((0, _toConsumableArray3.default)(keys)).reverse();
var parseDate = (0, _d3TimeFormat.timeParse)('%Y %b %d');
var _x = function _x(d) {
  return parseDate(d.date);
};
var stack = (0, _d3Shape.stack)().keys(keys);

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

  if (width < 10) return null;

  // bounds
  var yMax = height - margin.top - margin.bottom;
  var xMax = width - margin.left - margin.right;

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

  return _react2.default.createElement('svg', { width: width, height: height, __source: {
      fileName: _jsxFileName,
      lineNumber: 34
    }
  }, _react2.default.createElement(_gradient.GradientOrangeRed, { id: 'OrangeRed', __source: {
      fileName: _jsxFileName,
      lineNumber: 35
    }
  }), _react2.default.createElement('rect', { x: 0, y: 0, width: width, height: height, fill: '#f38181', rx: 14, __source: {
      fileName: _jsxFileName,
      lineNumber: 36
    }
  }), _react2.default.createElement(_shape.AreaStack, {
    reverse: true,
    top: margin.top,
    left: margin.left,
    keys: keys,
    data: data,
    x: function x(d) {
      return xScale(_x(d.data));
    },
    y0: function y0(d) {
      return yScale(d[0] / 100);
    },
    y1: function y1(d) {
      return yScale(d[1] / 100);
    },
    strokeWidth: 0,
    fill: 'url(#OrangeRed)',
    fillOpacity: '1',
    __source: {
      fileName: _jsxFileName,
      lineNumber: 37
    }
  }));
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvdGlsZXMvc3RhY2tlZC5qcyJdLCJuYW1lcyI6WyJSZWFjdCIsIkFyZWFTdGFjayIsIkdyYWRpZW50T3JhbmdlUmVkIiwiYnJvd3NlclVzYWdlIiwic2NhbGVUaW1lIiwic2NhbGVMaW5lYXIiLCJleHRlbnQiLCJtYXgiLCJ0aW1lUGFyc2UiLCJzdGFjayIsImQzc3RhY2siLCJkYXRhIiwia2V5cyIsImZpbHRlciIsImsiLCJicm93c2VyTmFtZXMiLCJyZXZlcnNlIiwicGFyc2VEYXRlIiwieCIsImQiLCJkYXRlIiwid2lkdGgiLCJoZWlnaHQiLCJtYXJnaW4iLCJ5TWF4IiwidG9wIiwiYm90dG9tIiwieE1heCIsImxlZnQiLCJyaWdodCIsInhTY2FsZSIsInJhbmdlIiwiZG9tYWluIiwieVNjYWxlIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7OztBQUFBLEFBQU87Ozs7QUFDUCxBQUFTOztBQUNULEFBQVM7O0FBQ1QsQUFBUzs7QUFDVCxBQUFTLEFBQVc7O0FBQ3BCLEFBQVMsQUFBUTs7QUFDakIsQUFBUzs7QUFDVCxBQUFTLEFBQVM7Ozs7Ozs7QUFFbEIsSUFBQSxBQUFNLEFBQU87QUFDYixJQUFNLDJCQUFtQixLQUFaLEFBQVksQUFBSyxJQUFqQixBQUFxQixPQUFPLGFBQUE7U0FBSyxNQUFMLEFBQVc7QUFBcEQsQUFBYSxDQUFBO0FBQ2IsSUFBTSxlQUFlLDJ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