import { CLS_PREFIX } from '../../../common/constants'; import { DrillDownDimensionType, FieldType, MsgDataType } from '../../../common/type'; import { isMobile } from '../../../utils/utils'; import MetricTrendChart from './MetricTrendChart'; import { Spin, Select } from 'antd'; import Table from '../Table'; import MetricInfo from './MetricInfo'; import DateOptions from '../DateOptions'; import MultiMetricsTrendChart from './MultiMetricsTrendChart'; import { useState } from 'react'; const metricChartSelectOptions = [ { value: 'line', label: '折线图', }, { value: 'bar', label: '柱状图', }, ]; type Props = { data: MsgDataType; question: string; chartIndex: number; triggerResize?: boolean; loading: boolean; activeMetricField?: FieldType; drillDownDimension?: DrillDownDimensionType; currentDateOption?: number; onApplyAuth?: (model: string) => void; onSelectDateOption: (value: number) => void; }; const MetricTrend: React.FC = ({ data, question, chartIndex, triggerResize, loading, activeMetricField, drillDownDimension, currentDateOption, onApplyAuth, onSelectDateOption, }) => { const { queryColumns, queryResults, aggregateInfo, entityInfo, chatContext } = data; const [chartType, setChartType] = useState('line'); const dateField: any = queryColumns?.find( (column: any) => column.showType === 'DATE' || column.type === 'DATE' ); const dateColumnName = dateField?.nameEn || ''; const categoryColumnName = queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.bizName || ''; const metricFields = queryColumns?.filter((column: any) => column.showType === 'NUMBER'); const currentMetricField = queryColumns?.find((column: any) => column.showType === 'NUMBER'); if (!currentMetricField) { return null; } const prefixCls = `${CLS_PREFIX}-metric-trend`; return (
{question}
{!isMobile && aggregateInfo?.metricInfos?.length > 0 && drillDownDimension === undefined && ( )}