/* eslint-disable no-restricted-syntax */
export default {
  computed: {
    simpleLegendData() {
      if (!this.chartOption) {
        return [];
      }
      const { series } = this.chartOption;
      const seriesArr = [];
      for (const item of series) {
        const { name, itemStyle } = item;
        let showName = name;
        const curIndex = this.indexValue.find(x => name.startsWith(`${x}_`));
        if (curIndex) {
          // eslint-disable-next-line prefer-destructuring
          showName = name.split(`${curIndex}_`)[1];
        }
        const obj = {
          name,
          showName,
          color: itemStyle?.color,
          selected: true,
        };
        seriesArr.push(obj);
      }
      return seriesArr;
    },
  },
};
