wujingjing
2024-10-17 ef721915b1a4afc33454e71460769bd3d7c264a9
src/components/chat/chatComponents/common.ts
@@ -1,5 +1,8 @@
import type * as echarts from 'echarts';
import { buildProps } from 'element-plus/es/utils/vue/props/runtime';
import _ from 'lodash';
import type { ExtractPropTypes, PropType } from 'vue';
import { axisLabelFormatter } from '/@/utils/chart';
export const timeDataOptionToContent = (opt) => {
   const headerList = [opt.xAxis[0]]
@@ -53,3 +56,71 @@
   },
} as const);
export type ChatComPropsType = ExtractPropTypes<typeof chatComProps>;
export const getChatChartOption = () => {
   const option = {
      grid: {
         // bottom: 120,
         // right: '15%',
         top: 65,
         left: 65,
         right: 45,
      },
      tooltip: {
         show: true,
         trigger: 'axis',
      },
      toolbox: {
         show: true,
         feature: {
            dataZoom: {
               yAxisIndex: 'none',
            },
            myBar: {
               title: '转化为柱状图',
               show: true,
               icon: PATH_ICON.bar,
            },
            myScatter: {
               title: '转化为散点图',
               show: true,
               icon: PATH_ICON.scatter,
            },
            myLine: {
               title: '转化为曲线图',
               show: true,
               icon: PATH_ICON.line,
            },
            // dataView: {
            //    readOnly: true,
            //    optionToContent: timeDataOptionToContent,
            // },
            saveAsImage: {},
         },
      },
      title: {
         left: 'center',
         textStyle: {
            fontSize: 14,
         },
      },
      xAxis: {
         type: 'time',
      },
      yAxis: {
         type: 'value',
         axisLabel: {
            formatter: axisLabelFormatter,
         },
      },
      dataZoom: {
         type: 'inside',
      },
   } as echarts.EChartsOption;
   return _.cloneDeep(option);
};