'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

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

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

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

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

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

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

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

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


var x = function x(d) {
  return new Date(d.date);
};
var y = function y(d) {
  return d.close;
};

var capPoints = [_mockData.appleStock[0]].concat([_mockData.appleStock[_mockData.appleStock.length - 1]]);

function LineRadialTile(_ref) {
  var width = _ref.width,
      height = _ref.height,
      _ref$margin = _ref.margin,
      margin = _ref$margin === undefined ? {
    top: 10,
    left: 10,
    right: 10,
    bottom: 120
  } : _ref$margin;

  if (width < 10) return null;

  var radius = Math.min(width, height) / 2;

  var xScale = (0, _scale.scaleTime)({
    range: [0, Math.PI * 2],
    domain: (0, _d3Array.extent)(_mockData.appleStock, x)
  });
  var yScale = (0, _scale.scaleLog)({
    range: [0, height / 2 - 20],
    domain: (0, _d3Array.extent)(_mockData.appleStock, y)
  });
  return _react2.default.createElement('svg', { width: width, height: height, __source: {
      fileName: _jsxFileName,
      lineNumber: 40
    }
  }, _react2.default.createElement(_gradient.LinearGradient, {
    from: '#e5fd3d',
    to: '#aeeef8',
    id: 'line-gradient',
    __source: {
      fileName: _jsxFileName,
      lineNumber: 41
    }
  }), _react2.default.createElement('rect', {
    x: 0,
    y: 0,
    width: width,
    height: height,
    fill: '#744cca',
    rx: 14,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 46
    }
  }), _react2.default.createElement(_group.Group, { top: height / 2, left: width / 2, __source: {
      fileName: _jsxFileName,
      lineNumber: 54
    }
  }, yScale.ticks().map(function (tick, i) {
    return _react2.default.createElement('g', { key: 'radial-grid-' + i, __source: {
        fileName: _jsxFileName,
        lineNumber: 57
      }
    }, _react2.default.createElement('circle', {
      r: yScale(tick),
      stroke: '#aeeef8',
      strokeWidth: 1,
      fill: '#aeeef8',
      fillOpacity: 1 / (i + 1) - 1 / i * 0.2,
      strokeOpacity: 0.2,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 58
      }
    }), _react2.default.createElement('text', {
      y: -yScale(tick),
      textAnchor: 'middle',
      dy: '-.33em',
      fontSize: 8,
      fill: '#aeeef8',
      fillOpacity: 0.6,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 66
      }
    }, tick));
  }), _react2.default.createElement(_shape.LineRadial, {
    data: _mockData.appleStock,
    angle: function angle(d) {
      return xScale(x(d));
    },
    radius: function radius(d) {
      return yScale(y(d));
    },
    fill: 'none',
    stroke: "url('#line-gradient')",
    strokeWidth: 2,
    strokeOpacity: 0.8,
    curve: _curve.curveBasisOpen,
    strokeLinecap: 'round',
    __source: {
      fileName: _jsxFileName,
      lineNumber: 79
    }
  }), capPoints.map(function (d, i) {
    return _react2.default.createElement('circle', {
      key: 'line-cap-' + i,
      cy: -yScale(y(d)),
      cx: xScale(x(d)) * Math.PI / 180,
      r: 3,
      fill: '#dff84d',
      __source: {
        fileName: _jsxFileName,
        lineNumber: 92
      }
    });
  })));
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvdGlsZXMvbGluZXJhZGlhbC5qcyJdLCJuYW1lcyI6WyJSZWFjdCIsIkdyb3VwIiwiTGluZVJhZGlhbCIsInNjYWxlVGltZSIsInNjYWxlTG9nIiwiY3VydmVCYXNpc09wZW4iLCJhcHBsZVN0b2NrIiwiZXh0ZW50IiwiTGluZWFyR3JhZGllbnQiLCJ4IiwiRGF0ZSIsImQiLCJkYXRlIiwieSIsImNsb3NlIiwiY2FwUG9pbnRzIiwiY29uY2F0IiwibGVuZ3RoIiwiTGluZVJhZGlhbFRpbGUiLCJ3aWR0aCIsIm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