'use strict';

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

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var ToolTip = function ToolTip(props) {
  var visibility = 'hidden';
  var transform = '';
  var x = 0;
  var y = 0;
  var width = 150;
  var height = 70;
  var transformText = 'translate(' + width / 2 + ', ' + (height / 2 - 5) + ')';
  var transformArrow = '';

  if (props.tooltip.display === true) {
    var position = props.tooltip.pos;
    x = position.x;
    y = position.y;
    visibility = 'visible';
    if (y > height) {
      transform = 'translate(' + (x - width / 2) + ', ' + (y - height - 20) + ')';
      transformArrow = 'translate(' + (width / 2 - 20) + ', ' + (height - 2) + ')';
    } else if (y < height) {
      transform = 'translate(' + (x - width / 2) + ', ' + (Math.round(y) + 20) + ')';
      transformArrow = 'translate(' + (width / 2 - 20) + ', 0) rotate(180, 20, 0)';
    }
  } else {
    visibility = 'hidden';
  }
  return _react2.default.createElement(
    'g',
    { transform: transform },
    _react2.default.createElement('rect', {
      'class': 'shadow',
      is: true,
      width: width,
      height: height,
      rx: '5',
      ry: '5',
      visibility: visibility,
      fill: '#6391da',
      opacity: '.9'
    }),
    _react2.default.createElement('polygon', {
      'class': 'shadow',
      is: true,
      points: '10,0  30,0  20,10',
      transform: transformArrow,
      fill: '#6391da',
      opacity: '.9',
      visibility: visibility
    }),
    _react2.default.createElement(
      'text',
      { is: true, visibility: visibility, transform: transformText },
      _react2.default.createElement(
        'tspan',
        { is: true, x: '0', 'text-anchor': 'middle', 'font-size': '15px', fill: '#ffffff' },
        props.tooltip.data.key
      ),
      _react2.default.createElement(
        'tspan',
        {
          is: true,
          x: '0',
          'text-anchor': 'middle',
          dy: '25',
          'font-size': '20px',
          fill: '#a9f3ff'
        },
        '' + props.tooltip.data.value
      )
    )
  );
};

ToolTip.propTypes = {
  tooltip: _propTypes2.default.object
};

exports.default = ToolTip;
//# sourceMappingURL=ToolTip.js.map