import * as React from 'react';
import ReactEcharts from 'echarts-for-react';
var BarBaseChart = function BarBaseChart(props) {
  var propData = props || {};
  var jsonData = props.data;
  var xdata = [];
  var ydata = [];
  // const  lineStyle = props.lineStyle || 3 s
  jsonData === null || jsonData === void 0 ? void 0 : jsonData.map(function (item) {
    xdata.push(item[props.xAxis]);
    ydata.push(item[props.yAxis]);
  });
  var echartsOption = {
    title: {
      text: propData.title
    },
    tooltip: {
      trigger: 'axis'
    },
    grid: {
      //占据全部位置
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      data: xdata,
      show: props.xAxisShow,
      //是否显示x坐标轴刻度
      axisTick: {
        alignWithLabel: props.axisTick //刻度线和标签对齐
      }
    },

    yAxis: {
      type: 'value',
      axisLine: {
        show: props.yaxisLine
      },
      //不显示坐标轴
      axisTick: {
        show: props.yaxisTick //不显示坐标轴刻度线
      },

      axisLabel: {
        show: props.yaxisLabel,
        // 不显示坐标轴上的文字
        formatter: function formatter(value, index) {
          return value + ' ' + props.yAxisaxisLabel;
        }
      }
    },
    series: [{
      //name:propData.title,
      type: 'bar',
      stack: '总量',
      data: ydata,
      barWidth: props.barWidth,
      //设置柱状图大小
      label: {
        //显示标签
        show: props.show,
        position: 'top',
        textStyle: {
          fontSize: props.labelsize,
          color: props.labelcolor
        },
        color: 'inherit'
      },
      itemStyle: {
        normal: {
          color: {
            type: 'linear',
            x: 0,
            //右
            y: 0,
            //下
            x2: 0,
            //左
            y2: 1,
            //上
            colorStops: [{
              offset: 0,
              color: props.inicolor // 0% 处的颜色
            }, {
              offset: 1,
              color: props.endcolor // 100% 处的颜色
            }]
          }
        }
      }
    }]
  };

  return (jsonData === null || jsonData === void 0 ? void 0 : jsonData.length) !== 0 ? /*#__PURE__*/React.createElement(ReactEcharts, {
    option: echartsOption,
    theme: "clear",
    style: {
      height: props.height,
      width: props.width
    }
  }) : /*#__PURE__*/React.createElement("div", {
    style: {
      height: props.height,
      width: props.width
    }
  }, "\u6682\u65E0\u6570\u636E");
};
export default BarBaseChart;