var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/CyBar/index.tsx
var CyBar_exports = {};
__export(CyBar_exports, {
  default: () => CyBar_default
});
module.exports = __toCommonJS(CyBar_exports);
var echarts = __toESM(require("echarts"));
var import_react = require("react");
var import_echarts_for_react = __toESM(require("echarts-for-react"));
var BarList = (props) => {
  const [option, setOption] = (0, import_react.useState)({});
  let { height, yLabel } = props;
  let showLabel = yLabel == "value" ? "{value}" : "{value} %";
  (0, import_react.useEffect)(() => {
    const datas = (props == null ? void 0 : props.data) || [];
    let optionNew = {
      backgroundColor: "transparent",
      grid: {
        left: "10",
        right: 0,
        bottom: "3%",
        top: "10%",
        containLabel: true
      },
      tooltip: {
        trigger: "axis",
        axisPointer: { type: "shadow" },
        valueFormatter: (value) => "$" + value.toFixed(2)
      },
      xAxis: {
        type: "category",
        data: datas == null ? void 0 : datas.map((item) => item == null ? void 0 : item.name),
        //数据
        axisLabel: {
          color: "white",
          formatter: (value) => {
            let a = value.slice(0, 2);
            let b = value.slice(2);
            let c = `${a}
${b}`;
            return c;
          },
          fontSize: 18
        },
        axisLine: {
          show: true
        },
        axisTick: false
      },
      yAxis: {
        type: "value",
        axisLine: {
          //坐标轴样式
          show: false
          //不显示
        },
        axisLabel: {
          color: "white",
          formatter: showLabel,
          fontSize: 18
        },
        splitLine: {
          //分隔辅助线
          lineStyle: {
            type: "dashed",
            //线的类型 虚线0
            opacity: 1
            //透明度
          }
        }
      },
      series: [
        {
          type: "pictorialBar",
          symbol: "rect",
          symbolSize: [40, 3],
          symbolOffset: [0, 0],
          itemStyle: {
            color: "#00BCFF"
          },
          tooltip: { show: false },
          data: datas == null ? void 0 : datas.map((item) => item == null ? void 0 : item.value)
        },
        {
          type: "bar",
          barWidth: 40,
          data: datas == null ? void 0 : datas.map((item) => item == null ? void 0 : item.value),
          itemStyle: {
            color: (params, api) => {
              if ((params == null ? void 0 : params.data) < 0) {
                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 1,
                    color: "#00BCFF"
                  },
                  {
                    offset: 0,
                    color: "rgba(51, 173, 234, 0)"
                  }
                ]);
              } else {
                return new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  {
                    offset: 0,
                    color: "#00BCFF"
                  },
                  {
                    offset: 1,
                    color: "rgba(51, 173, 234, 0)"
                  }
                ]);
              }
            }
          },
          label: {
            show: true,
            position: "top",
            // 位置
            color: "#fff",
            fontSize: 15,
            distance: 10
            // 距离
            // formatter: '{c}%' // 这里是数据展示的时候显示的数据
          }
        }
      ]
    };
    setOption(optionNew);
  }, [props == null ? void 0 : props.name]);
  return /* @__PURE__ */ React.createElement(import_echarts_for_react.default, { option, theme: "Imooc", ...props });
};
var CyBar_default = BarList;
