"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var Charts = function Charts(_ref) {
  var chartData = _ref.chartData,
    lineData = _ref.lineData;
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    isDark = _useSettings.isDark,
    theme = _useSettings.theme;
  var option = {
    color: chartColor,
    backgroundColor: 'transparent',
    tooltip: {
      show: true,
      trigger: 'item',
      formatter: function formatter(params) {
        var str = "".concat(params === null || params === void 0 ? void 0 : params.name);
        var color = params.color; // 获取系列的颜色
        str += "<div ><span style=\"color:".concat(color, ";font-size:24px \">\u2022</span> &nbsp;&nbsp;&nbsp;").concat(params.value, "\u6B21</div>");
        return str; // 返回带点的字符串
      }
    },
    legend: {
      orient: 'vertical',
      left: '50%',
      top: 'middle',
      align: 'left',
      itemGap: 12,
      itemWidth: 10,
      itemHeight: 10,
      formatter: function formatter(name) {
        var value = chartData.find(function (item) {
          return item.name === name;
        });
        if (value) {
          return "\t\t".concat(name, "\t\t").concat(value.value, "\u6B21\t\t");
        } else {
          return '';
        }
      },
      textStyle: {
        fontSize: 14,
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      pageIconColor: chartFontColor,
      pageIconInactiveColor: chartFontColor,
      pageTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    },
    series: [{
      type: 'pie',
      radius: ['55%', '75%'],
      center: ['40%', '50%'],
      hoverAnimation: true,
      z: 10,
      itemStyle: {
        normal: {
          borderWidth: 2,
          borderColor: isDark ? '#003359' : '#ffffff'
        }
      },
      label: {
        show: false
      },
      data: chartData === null || chartData === void 0 ? void 0 : chartData.filter(function (ele) {
        return ele.alarmTypeCode;
      }),
      labelLine: {
        show: false
      }
    }]
  };
  var legends = lineData.legends,
    names = lineData.names,
    values = lineData.values;
  var series = [];
  if ((values === null || values === void 0 ? void 0 : values.length) > 0) {
    values.forEach(function (item, index) {
      series.push({
        type: 'line',
        name: legends[index],
        data: item
      });
    });
  }
  var lineOption = {
    color: chartColor,
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a;
        var str = "<div  style=\"text-align:left\">".concat((_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.axisValue, "</div>");
        params.map(function (item) {
          str += "<div  style=\"text-align:left\"><span style=\"color:".concat(item === null || item === void 0 ? void 0 : item.color, " \">\u2022</span> ").concat(item.seriesName, " &nbsp;&nbsp;&nbsp;").concat(item.value, "\u6B21</div>");
        });
        return str; // 返回带点的字符串
      }
    },
    legend: {
      show: true,
      itemWith: 6,
      itemHeight: 6,
      top: 20,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor,
        fontSize: 12
      },
      data: legends || []
    },
    grid: {
      // top: 58,
      left: 24,
      bottom: 12,
      right: 40,
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: names || []
    },
    yAxis: [{
      name: '',
      type: 'value',
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      axisLine: {
        show: true
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }],
    series: series
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-alarm-charts"
  }, (chartData === null || chartData === void 0 ? void 0 : chartData.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '200px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      marginLeft: '50%',
      transform: 'translateX(-50%)'
    }
  })), (names === null || names === void 0 ? void 0 : names.length) && (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: lineOption,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  })));
};
var _default = exports["default"] = Charts;
//# sourceMappingURL=Charts.js.map
