'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _lodash = require('lodash.merge');

var _lodash2 = _interopRequireDefault(_lodash);

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

/** Default options for scatterplot container */
var gridOptions = {
  top: '24',
  right: '24',
  bottom: '24',
  left: '24'
};

/** Default options for x axis */
var xAxisOptions = {
  type: 'value',
  interval: 1,
  nameTextStyle: {
    fontSize: 14,
    fontWeight: 'bold'
  },
  nameLocation: 'center',
  nameGap: 16,
  splitLine: {
    show: false
  },
  axisLine: {
    show: false
  },
  axisTick: {
    show: false
  }

  /** Default options for y axis */
};var yAxisOptions = {
  type: 'value',
  splitLine: {
    show: true,
    lineStyle: {
      type: 'dashed',
      color: ['rgba(0,0,0,0.1)']
    }
  },
  axisTick: {
    show: false
  },
  axisLine: {
    show: false
  }
};

/** Default options for visual map */
var visualMapOptions = {
  dimension: 1,
  calculable: false,
  show: false
};

/**
 * Merge axis overrides with default axis options
 * @param {string} axisName 'x' or 'y'
 * @param {object} overrides https://ecomfe.github.io/echarts-doc/public/en/option.html#xAxis
 */
var getAxisOptions = function getAxisOptions(axisName) {
  var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  return (0, _lodash2.default)({}, axisName === 'x' ? xAxisOptions : yAxisOptions, overrides);
};

/**
 * Merge container overrides with default container options
 * @param {object} overrides https://ecomfe.github.io/echarts-doc/public/en/option.html#grid
 */
var getGridOptions = function getGridOptions() {
  var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  return (0, _lodash2.default)({}, gridOptions, overrides);
};

/**
 * Merge visual map overrides with default visual map options
 * @param {object} overrides https://ecomfe.github.io/echarts-doc/public/en/option.html#visualMap
 */
var getVisualMapOptions = function getVisualMapOptions() {
  var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  return overrides.map(function (vm) {
    return (0, _lodash2.default)({}, visualMapOptions, vm);
  });
};

/**
 * Gets the base scatterplot config with the provided overrides
 * @param {*} overrides any override options for the scatterplot
 */
var getScatterplotOptions = exports.getScatterplotOptions = function getScatterplotOptions() {
  var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  return _extends({}, overrides, {
    grid: getGridOptions(overrides.grid),
    xAxis: getAxisOptions('x', overrides.xAxis),
    yAxis: getAxisOptions('y', overrides.yAxis),
    visualMap: getVisualMapOptions(overrides.visualMap)
  });
};