'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: 38
    }
  }, _react2.default.createElement(_gradient.LinearGradient, { from: '#e5fd3d', to: '#aeeef8', id: 'line-gradient', __source: {
      fileName: _jsxFileName,
      lineNumber: 39
    }
  }), _react2.default.createElement('rect', { x: 0, y: 0, width: width, height: height, fill: '#744cca', rx: 14, __source: {
      fileName: _jsxFileName,
      lineNumber: 40
    }
  }), _react2.default.createElement(_group.Group, { top: height / 2, left: width / 2, __source: {
      fileName: _jsxFileName,
      lineNumber: 41
    }
  }, yScale.ticks().map(function (tick, i) {
    return _react2.default.createElement('g', { key: 'radial-grid-' + i, __source: {
        fileName: _jsxFileName,
        lineNumber: 44
      }
    }, _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: 45
      }
    }), _react2.default.createElement('text', {
      y: -yScale(tick),
      textAnchor: 'middle',
      dy: '-.33em',
      fontSize: 8,
      fill: '#aeeef8',
      fillOpacity: 0.6,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 53
      }
    }, 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: 66
    }
  }), 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: 79
      }
    });
  })));
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbXBvbmVudHMvdGlsZXMvbGluZXJhZGlhbC5qcyJdLCJuYW1lcyI6WyJSZWFjdCIsIkdyb3VwIiwiTGluZVJhZGlhbCIsInNjYWxlVGltZSIsInNjYWxlTG9nIiwiY3VydmVCYXNpc09wZW4iLCJhcHBsZVN0b2NrIiwiZXh0ZW50IiwiTGluZWFyR3JhZGllbnQiLCJ4IiwiRGF0ZSIsImQiLCJkYXRlIiwieSIsImNsb3NlIiwiY2FwUG9pbnRzIiwiY29uY2F0IiwibGVuZ3RoIiwiTGluZVJhZGlhbFRpbGUiLCJ3aWR0aCIsImhlaWdodCIsIm1hcmdpbiIs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