"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var React = _interopRequireWildcard(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var StripChart = function StripChart(props) {
  var propData = props || {};
  var jsonData = props.data;
  var xdata = [];
  var ydata = [];
  // const  lineStyle = props.lineStyle || 3 
  jsonData.map(function (item) {
    xdata.push(item[props.xAxis]);
    ydata.push(item[props.yAxis]);
  });
  var echartsOption = {
    title: {
      text: propData.title
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {//需要对应 series 的 name值
      // data: ['天海湾', '鼎龙湾', '珍珠湾', '翠逸家园', '紫林湾']
    },
    color: propData.color,
    grid: {
      top: '3%',
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    // toolbox: {
    //     feature: {
    //         dataView: { show: true, readOnly: false },
    //         magicType: { show: true, type: ['line', 'bar'] },
    //         saveAsImage: {} //存取为图片
    //     }
    // },
    xAxis: {
      type: 'value',
      name: props.xAxisaxisLabel,
      //配置name(单位),
      // nameLocation:'end',
      nameTextStyle: {
        padding: [0, 0, 0, 0, 0] // 加上padding可以调整其位置
      },

      boundaryGap: false
    },
    yAxis: {
      type: 'category',
      data: xdata
    },
    series: [{
      //name:propData.title,
      type: 'bar',
      stack: '总量',
      data: ydata,
      barWidth: props.barWidth,
      //配置大小
      smooth: props.smooth,
      //平滑
      showSymbol: props.showSymbol,
      //显示点
      color: {
        colorStops: [{
          offset: 0,
          color: propData.initialColor
        }, {
          offset: 1,
          color: propData.endColor
        }]
      },
      label: {
        //显示标签
        show: props.show,
        position: ['100%', '40%']
      },
      itemStyle: {
        normal: {
          lineStyle: {
            width: props.lineStyle || 2 //设置线条粗细
          }
        }
      }
    }]
  };

  return /*#__PURE__*/React.createElement(_echartsForReact["default"], {
    style: {
      width: props.setWidth,
      height: props.setheight,
      zIndex: 222
    },
    option: echartsOption,
    theme: "clear"
  });
};
var _default = StripChart;
exports["default"] = _default;