test-chat-sdk 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.js +24 -0
- package/README.md +46 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +77 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +785 -0
- package/config/webpackDevServer.config.js +127 -0
- package/dist/Chat/AgentList/index.d.ts +9 -0
- package/dist/Chat/ChatFooter/index.d.ts +17 -0
- package/dist/Chat/Conversation/index.d.ts +11 -0
- package/dist/Chat/MessageContainer/index.d.ts +19 -0
- package/dist/Chat/MobileAgents/index.d.ts +11 -0
- package/dist/Chat/components/AgentTip/index.d.ts +8 -0
- package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
- package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
- package/dist/Chat/components/Message.d.ts +10 -0
- package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
- package/dist/Chat/components/Text.d.ts +9 -0
- package/dist/Chat/constants.d.ts +19 -0
- package/dist/Chat/index.d.ts +17 -0
- package/dist/Chat/service.d.ts +11 -0
- package/dist/Chat/type.d.ts +97 -0
- package/dist/Copilot/constants.d.ts +11 -0
- package/dist/Copilot/index.d.ts +13 -0
- package/dist/ShowCase/index.d.ts +8 -0
- package/dist/ShowCase/service.d.ts +2 -0
- package/dist/ShowCase/type.d.ts +11 -0
- package/dist/common/constants.d.ts +58 -0
- package/dist/common/env.d.ts +3 -0
- package/dist/common/type.d.ts +247 -0
- package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
- package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
- package/dist/components/ChatItem/FilterItem.d.ts +17 -0
- package/dist/components/ChatItem/Loading.d.ts +2 -0
- package/dist/components/ChatItem/ParseTip.d.ts +26 -0
- package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
- package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
- package/dist/components/ChatItem/SqlItem.d.ts +17 -0
- package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
- package/dist/components/ChatItem/Text.d.ts +6 -0
- package/dist/components/ChatItem/Typing.d.ts +2 -0
- package/dist/components/ChatItem/index.d.ts +33 -0
- package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
- package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
- package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
- package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
- package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
- package/dist/components/ChatMsg/Message/index.d.ts +18 -0
- package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
- package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
- package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
- package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
- package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
- package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
- package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
- package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
- package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
- package/dist/components/ChatMsg/Table/index.d.ts +12 -0
- package/dist/components/ChatMsg/Text/index.d.ts +9 -0
- package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
- package/dist/components/ChatMsg/index.d.ts +15 -0
- package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
- package/dist/components/DrillDownDimensions/index.d.ts +13 -0
- package/dist/components/IconFont/index.d.ts +3 -0
- package/dist/components/MetricOptions/index.d.ts +11 -0
- package/dist/components/RecommendOptions/index.d.ts +9 -0
- package/dist/components/Tools/FeedbackModal.d.ts +9 -0
- package/dist/components/Tools/index.d.ts +12 -0
- package/dist/demo/Chat.d.ts +2 -0
- package/dist/demo/ChatDemo.d.ts +4 -0
- package/dist/demo/CopilotDemo.d.ts +2 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useComposing.d.ts +5 -0
- package/dist/hooks/useExportByEcharts.d.ts +10 -0
- package/dist/hooks/useMethodRegister.d.ts +4 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.es.js +1 -0
- package/dist/service/axiosInstance.d.ts +3 -0
- package/dist/service/index.d.ts +25 -0
- package/dist/utils/utils.d.ts +45 -0
- package/package.json +214 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/manifest.json +15 -0
- package/public/robots.txt +3 -0
- package/rollup/rollup.config.mjs +37 -0
- package/rollup/rollup.esm.config.mjs +21 -0
- package/rollup/rollup.umd.config.mjs +30 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +154 -0
- package/scripts/test.js +52 -0
- package/src/Chat/AgentList/index.tsx +52 -0
- package/src/Chat/AgentList/style.module.less +83 -0
- package/src/Chat/ChatFooter/index.tsx +423 -0
- package/src/Chat/ChatFooter/style.module.less +225 -0
- package/src/Chat/Conversation/index.tsx +236 -0
- package/src/Chat/Conversation/style.module.less +171 -0
- package/src/Chat/MessageContainer/index.tsx +145 -0
- package/src/Chat/MessageContainer/style.module.less +53 -0
- package/src/Chat/MobileAgents/index.tsx +62 -0
- package/src/Chat/MobileAgents/style.module.less +55 -0
- package/src/Chat/components/AgentTip/index.tsx +48 -0
- package/src/Chat/components/AgentTip/style.module.less +44 -0
- package/src/Chat/components/ConversationModal/index.tsx +65 -0
- package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
- package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
- package/src/Chat/components/Message.tsx +38 -0
- package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
- package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
- package/src/Chat/components/Text.tsx +42 -0
- package/src/Chat/components/style.module.less +311 -0
- package/src/Chat/constants.ts +37 -0
- package/src/Chat/index.tsx +526 -0
- package/src/Chat/service.ts +49 -0
- package/src/Chat/style.module.less +119 -0
- package/src/Chat/type.ts +107 -0
- package/src/Copilot/constants.ts +11 -0
- package/src/Copilot/index.tsx +149 -0
- package/src/Copilot/style.module.less +151 -0
- package/src/ShowCase/index.tsx +120 -0
- package/src/ShowCase/service.ts +12 -0
- package/src/ShowCase/style.module.less +46 -0
- package/src/ShowCase/type.ts +14 -0
- package/src/common/constants.ts +93 -0
- package/src/common/env.ts +5 -0
- package/src/common/type.ts +270 -0
- package/src/components/ChatItem/ExecuteItem.tsx +210 -0
- package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
- package/src/components/ChatItem/FilterItem.tsx +209 -0
- package/src/components/ChatItem/Loading.tsx +14 -0
- package/src/components/ChatItem/ParseTip.tsx +322 -0
- package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
- package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
- package/src/components/ChatItem/SqlItem.tsx +410 -0
- package/src/components/ChatItem/SwitchEntity.tsx +52 -0
- package/src/components/ChatItem/Text.tsx +17 -0
- package/src/components/ChatItem/Typing.tsx +19 -0
- package/src/components/ChatItem/index.tsx +843 -0
- package/src/components/ChatItem/style.less +670 -0
- package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
- package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
- package/src/components/ChatMsg/Bar/index.tsx +208 -0
- package/src/components/ChatMsg/Bar/style.less +60 -0
- package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
- package/src/components/ChatMsg/DateOptions/style.less +43 -0
- package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
- package/src/components/ChatMsg/FilterSection/style.less +37 -0
- package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
- package/src/components/ChatMsg/MarkDown/style.less +9 -0
- package/src/components/ChatMsg/Message/index.tsx +105 -0
- package/src/components/ChatMsg/Message/style.less +119 -0
- package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
- package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
- package/src/components/ChatMsg/MetricCard/style.less +126 -0
- package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
- package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
- package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
- package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
- package/src/components/ChatMsg/MetricTrend/style.less +195 -0
- package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
- package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
- package/src/components/ChatMsg/Pie/PieChart.tsx +120 -0
- package/src/components/ChatMsg/Pie/index.tsx +88 -0
- package/src/components/ChatMsg/Pie/style.less +43 -0
- package/src/components/ChatMsg/Table/index.tsx +103 -0
- package/src/components/ChatMsg/Table/style.less +131 -0
- package/src/components/ChatMsg/Text/index.tsx +70 -0
- package/src/components/ChatMsg/Text/style.less +38 -0
- package/src/components/ChatMsg/WebPage/index.tsx +125 -0
- package/src/components/ChatMsg/index.tsx +428 -0
- package/src/components/ChatMsg/style.less +28 -0
- package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
- package/src/components/DrillDownDimensions/index.tsx +76 -0
- package/src/components/DrillDownDimensions/style.less +64 -0
- package/src/components/IconFont/index.tsx +7 -0
- package/src/components/MetricOptions/index.tsx +75 -0
- package/src/components/MetricOptions/style.less +69 -0
- package/src/components/RecommendOptions/index.tsx +126 -0
- package/src/components/RecommendOptions/style.less +24 -0
- package/src/components/Tools/FeedbackModal.tsx +55 -0
- package/src/components/Tools/index.tsx +126 -0
- package/src/components/Tools/style.less +67 -0
- package/src/demo/Chat.tsx +73 -0
- package/src/demo/ChatDemo.tsx +14 -0
- package/src/demo/CopilotDemo.tsx +43 -0
- package/src/demo/style.module.less +19 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useComposing.ts +31 -0
- package/src/hooks/useExportByEcharts.ts +41 -0
- package/src/hooks/useMethodRegister.ts +25 -0
- package/src/index.tsx +44 -0
- package/src/service/axiosInstance.ts +58 -0
- package/src/service/index.ts +174 -0
- package/src/setupProxy.js +18 -0
- package/src/setupTests.ts +5 -0
- package/src/styles/global.less +52 -0
- package/src/styles/index.less +39 -0
- package/src/styles/reboot.less +14 -0
- package/src/styles/variables.less +80 -0
- package/src/typings.d.ts +179 -0
- package/src/utils/utils.ts +346 -0
- package/tsconfig.build.json +20 -0
- package/tsconfig.json +27 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { CLS_PREFIX } from '../../../common/constants';
|
|
2
|
+
import { DrillDownDimensionType, FieldType, MsgDataType } from '../../../common/type';
|
|
3
|
+
import { isMobile } from '../../../utils/utils';
|
|
4
|
+
import MetricTrendChart from './MetricTrendChart';
|
|
5
|
+
import { Spin, Select } from 'antd';
|
|
6
|
+
import Table from '../Table';
|
|
7
|
+
import MetricInfo from './MetricInfo';
|
|
8
|
+
import DateOptions from '../DateOptions';
|
|
9
|
+
import MultiMetricsTrendChart from './MultiMetricsTrendChart';
|
|
10
|
+
import { useState } from 'react';
|
|
11
|
+
|
|
12
|
+
const metricChartSelectOptions = [
|
|
13
|
+
{
|
|
14
|
+
value: 'line',
|
|
15
|
+
label: '折线图',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: 'bar',
|
|
19
|
+
label: '柱状图',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
type Props = {
|
|
24
|
+
data: MsgDataType;
|
|
25
|
+
question: string;
|
|
26
|
+
chartIndex: number;
|
|
27
|
+
triggerResize?: boolean;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
activeMetricField?: FieldType;
|
|
30
|
+
drillDownDimension?: DrillDownDimensionType;
|
|
31
|
+
currentDateOption?: number;
|
|
32
|
+
onApplyAuth?: (model: string) => void;
|
|
33
|
+
onSelectDateOption: (value: number) => void;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const MetricTrend: React.FC<Props> = ({
|
|
37
|
+
data,
|
|
38
|
+
question,
|
|
39
|
+
chartIndex,
|
|
40
|
+
triggerResize,
|
|
41
|
+
loading,
|
|
42
|
+
activeMetricField,
|
|
43
|
+
drillDownDimension,
|
|
44
|
+
currentDateOption,
|
|
45
|
+
onApplyAuth,
|
|
46
|
+
onSelectDateOption,
|
|
47
|
+
}) => {
|
|
48
|
+
const { queryColumns, queryResults, aggregateInfo, entityInfo, chatContext } = data;
|
|
49
|
+
const [chartType, setChartType] = useState('line');
|
|
50
|
+
|
|
51
|
+
const dateField: any = queryColumns?.find(
|
|
52
|
+
(column: any) => column.showType === 'DATE' || column.type === 'DATE'
|
|
53
|
+
);
|
|
54
|
+
const dateColumnName = dateField?.bizName || '';
|
|
55
|
+
const categoryColumnName =
|
|
56
|
+
queryColumns?.find((column: any) => column.showType === 'CATEGORY')?.bizName || '';
|
|
57
|
+
const metricFields = queryColumns?.filter((column: any) => column.showType === 'NUMBER');
|
|
58
|
+
|
|
59
|
+
const currentMetricField = queryColumns?.find((column: any) => column.showType === 'NUMBER');
|
|
60
|
+
|
|
61
|
+
if (!currentMetricField) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const prefixCls = `${CLS_PREFIX}-metric-trend`;
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div className={prefixCls}>
|
|
69
|
+
<div className={`${prefixCls}-charts`}>
|
|
70
|
+
<div className={`${prefixCls}-top-bar`}>
|
|
71
|
+
<div className={`${prefixCls}-metric-fields ${prefixCls}-metric-field-single`}>
|
|
72
|
+
{question}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<Spin spinning={loading}>
|
|
76
|
+
<div className={`${prefixCls}-content`}>
|
|
77
|
+
{!isMobile &&
|
|
78
|
+
aggregateInfo?.metricInfos?.length > 0 &&
|
|
79
|
+
drillDownDimension === undefined && (
|
|
80
|
+
<MetricInfo aggregateInfo={aggregateInfo} currentMetricField={currentMetricField} />
|
|
81
|
+
)}
|
|
82
|
+
<div className={`${prefixCls}-select-options`}>
|
|
83
|
+
<DateOptions
|
|
84
|
+
chatContext={chatContext}
|
|
85
|
+
currentDateOption={currentDateOption}
|
|
86
|
+
onSelectDateOption={onSelectDateOption}
|
|
87
|
+
/>
|
|
88
|
+
<div>
|
|
89
|
+
<Select
|
|
90
|
+
defaultValue="line"
|
|
91
|
+
bordered={false}
|
|
92
|
+
options={metricChartSelectOptions}
|
|
93
|
+
onChange={(value: string) => setChartType(value)}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
{queryResults?.length === 1 || chartIndex % 2 === 1 ? (
|
|
98
|
+
<Table data={{ ...data, queryResults }} onApplyAuth={onApplyAuth} />
|
|
99
|
+
) : metricFields.length > 1 ? (
|
|
100
|
+
<MultiMetricsTrendChart
|
|
101
|
+
dateColumnName={dateColumnName}
|
|
102
|
+
metricFields={metricFields}
|
|
103
|
+
question={question}
|
|
104
|
+
resultList={queryResults}
|
|
105
|
+
triggerResize={triggerResize}
|
|
106
|
+
chartType={chartType}
|
|
107
|
+
/>
|
|
108
|
+
) : (
|
|
109
|
+
<MetricTrendChart
|
|
110
|
+
model={entityInfo?.dataSetInfo.name}
|
|
111
|
+
dateColumnName={dateColumnName}
|
|
112
|
+
categoryColumnName={categoryColumnName}
|
|
113
|
+
metricField={currentMetricField}
|
|
114
|
+
resultList={queryResults}
|
|
115
|
+
triggerResize={triggerResize}
|
|
116
|
+
onApplyAuth={onApplyAuth}
|
|
117
|
+
chartType={chartType}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
</Spin>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default MetricTrend;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@metric-trend-prefix-cls: ~'@{supersonic-chat-prefix}-metric-trend';
|
|
4
|
+
|
|
5
|
+
@metric-info-prefix-cls: ~'@{supersonic-chat-prefix}-metric-info';
|
|
6
|
+
|
|
7
|
+
.@{metric-trend-prefix-cls} {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
margin-top: 4px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
row-gap: 4px;
|
|
15
|
+
|
|
16
|
+
&-top-bar {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: baseline;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
row-gap: 12px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-filter-section-wrapper {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
color: var(--text-color-third);
|
|
27
|
+
margin-left: 4px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-filter-section {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
font-size: 13px;
|
|
34
|
+
column-gap: 12px;
|
|
35
|
+
color: var(--text-color-third);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-filter-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&-filter-item-label {
|
|
44
|
+
color: var(--text-color-third);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&-filter-item-value {
|
|
48
|
+
color: var(--text-color);
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&-content {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
width: 100%;
|
|
56
|
+
row-gap: 12px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&-select-options {
|
|
60
|
+
display: flex;
|
|
61
|
+
justify-content: space-between;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&-indicator {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: baseline;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&-date-range {
|
|
72
|
+
color: var(--text-color-fourth);
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
&-indicator-value {
|
|
77
|
+
color: var(--text-color);
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
font-size: 30px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&-indicator-name {
|
|
83
|
+
color: var(--text-color-fourth);
|
|
84
|
+
font-size: 14px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&-flow-trend-chart {
|
|
88
|
+
margin-top: 4px;
|
|
89
|
+
height: 230px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&-flow-trend-chart-single {
|
|
93
|
+
height: 180px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&-charts {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
width: 100%;
|
|
100
|
+
row-gap: 8px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&-metric-fields {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-wrap: wrap;
|
|
106
|
+
align-items: center;
|
|
107
|
+
row-gap: 12px;
|
|
108
|
+
color: var(--text-color);
|
|
109
|
+
font-size: 15px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&-metric-field {
|
|
113
|
+
display: inline-block;
|
|
114
|
+
box-sizing: border-box;
|
|
115
|
+
height: auto;
|
|
116
|
+
margin: 0;
|
|
117
|
+
margin-right: 8px;
|
|
118
|
+
padding: 1px 8px;
|
|
119
|
+
color: var(--text-color-third);
|
|
120
|
+
font-variant: tabular-nums;
|
|
121
|
+
line-height: 20px;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
list-style: none;
|
|
124
|
+
border-color: transparent;
|
|
125
|
+
border-radius: 2px;
|
|
126
|
+
cursor: pointer;
|
|
127
|
+
opacity: 1;
|
|
128
|
+
transition: all 0.3s;
|
|
129
|
+
font-feature-settings: 'tnum', 'tnum';
|
|
130
|
+
|
|
131
|
+
&:hover {
|
|
132
|
+
color: var(--chat-blue);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&-metric-field-single {
|
|
137
|
+
padding-left: 0;
|
|
138
|
+
font-weight: 500;
|
|
139
|
+
cursor: default;
|
|
140
|
+
font-size: 15px;
|
|
141
|
+
color: var(--text-color);
|
|
142
|
+
|
|
143
|
+
&:hover {
|
|
144
|
+
color: var(--text-color);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.@{metric-info-prefix-cls} {
|
|
150
|
+
&-indicator {
|
|
151
|
+
display: flex;
|
|
152
|
+
align-items: baseline;
|
|
153
|
+
column-gap: 12px;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&-indicator-value {
|
|
157
|
+
color: var(--text-color);
|
|
158
|
+
font-weight: 500;
|
|
159
|
+
font-size: 28px;
|
|
160
|
+
line-height: 40px;
|
|
161
|
+
margin-top: 2px;
|
|
162
|
+
color: var(--text-color-secondary);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&-bottom-section {
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
column-gap: 20px;
|
|
169
|
+
margin-top: 4px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&-date {
|
|
173
|
+
color: var(--text-color-fourth);
|
|
174
|
+
font-size: 13px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&-date-value {
|
|
178
|
+
color: var(--chat-blue);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&-indicator-switch {
|
|
182
|
+
color: var(--text-color-fourth);
|
|
183
|
+
font-size: 18px;
|
|
184
|
+
margin-left: 6px;
|
|
185
|
+
margin-bottom: 3px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&-period-compare {
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
column-gap: 20px;
|
|
192
|
+
font-size: 13px;
|
|
193
|
+
overflow-x: auto;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { CLS_PREFIX } from '../../../common/constants';
|
|
3
|
+
import ApplyAuth from '../ApplyAuth';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
model: string;
|
|
7
|
+
chartType?: string;
|
|
8
|
+
onApplyAuth?: (model: string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const NoPermissionChart: React.FC<Props> = ({ model, chartType, onApplyAuth }) => {
|
|
12
|
+
const prefixCls = `${CLS_PREFIX}-no-permission-chart`;
|
|
13
|
+
|
|
14
|
+
const chartHolderClass = classNames(`${prefixCls}-holder`, {
|
|
15
|
+
[`${prefixCls}-bar-chart-holder`]: chartType === 'barChart',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className={prefixCls}>
|
|
20
|
+
<div className={chartHolderClass} />
|
|
21
|
+
<div className={`${prefixCls}-no-permission`}>
|
|
22
|
+
<ApplyAuth model={model} onApplyAuth={onApplyAuth} />
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default NoPermissionChart;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@no-permission-chart-prefix-cls: ~'@{supersonic-chat-prefix}-no-permission-chart';
|
|
4
|
+
|
|
5
|
+
.@{no-permission-chart-prefix-cls} {
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 300px;
|
|
9
|
+
|
|
10
|
+
&-holder {
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 280px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&-bar-chart-holder {
|
|
16
|
+
margin-top: 20px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&-no-permission {
|
|
20
|
+
position: absolute;
|
|
21
|
+
top: 50%;
|
|
22
|
+
left: 50%;
|
|
23
|
+
padding: 4px 12px;
|
|
24
|
+
transform: translate(-50%, -50%);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { PREFIX_CLS, THEME_COLOR_LIST } from '../../../common/constants';
|
|
2
|
+
import { MsgDataType } from '../../../common/type';
|
|
3
|
+
import { formatByDataFormatType, getFormattedValue } from '../../../utils/utils';
|
|
4
|
+
import type { ECharts } from 'echarts';
|
|
5
|
+
import * as echarts from 'echarts';
|
|
6
|
+
import { useEffect, useRef } from 'react';
|
|
7
|
+
import { ColumnType } from '../../../common/type';
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
data: MsgDataType;
|
|
11
|
+
metricField: ColumnType;
|
|
12
|
+
categoryField: ColumnType;
|
|
13
|
+
triggerResize?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const PieChart: React.FC<Props> = ({
|
|
17
|
+
data,
|
|
18
|
+
metricField,
|
|
19
|
+
categoryField,
|
|
20
|
+
triggerResize,
|
|
21
|
+
}) => {
|
|
22
|
+
const chartRef = useRef<any>();
|
|
23
|
+
const instanceRef = useRef<ECharts>();
|
|
24
|
+
|
|
25
|
+
const { queryResults } = data;
|
|
26
|
+
const categoryColumnName = categoryField?.bizName || '';
|
|
27
|
+
const metricColumnName = metricField?.bizName || '';
|
|
28
|
+
|
|
29
|
+
const renderChart = () => {
|
|
30
|
+
let instanceObj: any;
|
|
31
|
+
if (!instanceRef.current) {
|
|
32
|
+
instanceObj = echarts.init(chartRef.current);
|
|
33
|
+
instanceRef.current = instanceObj;
|
|
34
|
+
} else {
|
|
35
|
+
instanceObj = instanceRef.current;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const data = queryResults || [];
|
|
39
|
+
const seriesData = data.map((item, index) => {
|
|
40
|
+
const value = item[metricColumnName];
|
|
41
|
+
const name = item[categoryColumnName] !== undefined ? item[categoryColumnName] : '未知';
|
|
42
|
+
return {
|
|
43
|
+
name,
|
|
44
|
+
value,
|
|
45
|
+
itemStyle: {
|
|
46
|
+
color: THEME_COLOR_LIST[index % THEME_COLOR_LIST.length],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
instanceObj.setOption({
|
|
52
|
+
tooltip: {
|
|
53
|
+
trigger: 'item',
|
|
54
|
+
formatter: function (params: any) {
|
|
55
|
+
const value = params.value;
|
|
56
|
+
return `${params.name}: ${
|
|
57
|
+
metricField.dataFormatType === 'percent'
|
|
58
|
+
? formatByDataFormatType(value, metricField.dataFormatType, metricField.dataFormat)
|
|
59
|
+
: getFormattedValue(value)
|
|
60
|
+
}`;
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
legend: {
|
|
64
|
+
orient: 'vertical',
|
|
65
|
+
left: 'left',
|
|
66
|
+
type: 'scroll',
|
|
67
|
+
data: seriesData.map(item => item.name),
|
|
68
|
+
selectedMode: true,
|
|
69
|
+
textStyle: {
|
|
70
|
+
color: '#666',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
series: [
|
|
74
|
+
{
|
|
75
|
+
name: '占比',
|
|
76
|
+
type: 'pie',
|
|
77
|
+
radius: ['40%', '70%'],
|
|
78
|
+
avoidLabelOverlap: false,
|
|
79
|
+
itemStyle: {
|
|
80
|
+
borderRadius: 10,
|
|
81
|
+
borderColor: '#fff',
|
|
82
|
+
borderWidth: 2,
|
|
83
|
+
},
|
|
84
|
+
label: {
|
|
85
|
+
show: false,
|
|
86
|
+
position: 'center',
|
|
87
|
+
},
|
|
88
|
+
emphasis: {
|
|
89
|
+
label: {
|
|
90
|
+
show: true,
|
|
91
|
+
fontSize: '14',
|
|
92
|
+
fontWeight: 'bold',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
labelLine: {
|
|
96
|
+
show: false,
|
|
97
|
+
},
|
|
98
|
+
data: seriesData,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
instanceObj.resize();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (queryResults && queryResults.length > 0) {
|
|
107
|
+
renderChart();
|
|
108
|
+
}
|
|
109
|
+
}, [queryResults, metricField, categoryField]);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (triggerResize && instanceRef.current) {
|
|
113
|
+
instanceRef.current.resize();
|
|
114
|
+
}
|
|
115
|
+
}, [triggerResize]);
|
|
116
|
+
|
|
117
|
+
return <div className={`${PREFIX_CLS}-pie-chart`} ref={chartRef} />;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default PieChart;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PREFIX_CLS } from '../../../common/constants';
|
|
2
|
+
import { MsgDataType } from '../../../common/type';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import NoPermissionChart from '../NoPermissionChart';
|
|
5
|
+
import { ColumnType } from '../../../common/type';
|
|
6
|
+
import { Spin, Select } from 'antd';
|
|
7
|
+
import PieChart from './PieChart';
|
|
8
|
+
import Bar from '../Bar';
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
data: MsgDataType;
|
|
12
|
+
question: string;
|
|
13
|
+
triggerResize?: boolean;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
metricField: ColumnType;
|
|
16
|
+
categoryField: ColumnType;
|
|
17
|
+
onApplyAuth?: (model: string) => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const metricChartSelectOptions = [
|
|
21
|
+
{
|
|
22
|
+
value: 'pie',
|
|
23
|
+
label: '饼图',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
value: 'bar',
|
|
27
|
+
label: '柱状图',
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const Pie: React.FC<Props> = ({
|
|
32
|
+
data,
|
|
33
|
+
question,
|
|
34
|
+
triggerResize,
|
|
35
|
+
loading,
|
|
36
|
+
metricField,
|
|
37
|
+
categoryField,
|
|
38
|
+
onApplyAuth,
|
|
39
|
+
}) => {
|
|
40
|
+
const [chartType, setChartType] = useState('pie');
|
|
41
|
+
const { entityInfo } = data;
|
|
42
|
+
|
|
43
|
+
if (metricField && !metricField?.authorized) {
|
|
44
|
+
return (
|
|
45
|
+
<NoPermissionChart
|
|
46
|
+
model={entityInfo?.dataSetInfo?.name || ''}
|
|
47
|
+
chartType="pieChart"
|
|
48
|
+
onApplyAuth={onApplyAuth}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const prefixCls = `${PREFIX_CLS}-pie`;
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className={prefixCls}>
|
|
57
|
+
<div className={`${prefixCls}-metric-fields ${prefixCls}-metric-field-single`}>
|
|
58
|
+
{question}
|
|
59
|
+
</div>
|
|
60
|
+
<div className={`${prefixCls}-select-options`}>
|
|
61
|
+
<Select
|
|
62
|
+
defaultValue="pie"
|
|
63
|
+
bordered={false}
|
|
64
|
+
options={metricChartSelectOptions}
|
|
65
|
+
onChange={(value: string) => setChartType(value)}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
{chartType === 'pie' ? (
|
|
69
|
+
<PieChart
|
|
70
|
+
data={data}
|
|
71
|
+
metricField={metricField}
|
|
72
|
+
categoryField={categoryField}
|
|
73
|
+
triggerResize={triggerResize}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<Bar
|
|
77
|
+
data={data}
|
|
78
|
+
triggerResize={triggerResize}
|
|
79
|
+
loading={loading}
|
|
80
|
+
metricField={metricField}
|
|
81
|
+
onApplyAuth={onApplyAuth}
|
|
82
|
+
/>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export default Pie;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import '../../../styles/index.less';
|
|
2
|
+
|
|
3
|
+
@pie-prefix-cls: ~'@{prefix-cls}-pie';
|
|
4
|
+
|
|
5
|
+
.@{pie-prefix-cls} {
|
|
6
|
+
&-select-options {
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: flex-end;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&-chart {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 400px;
|
|
14
|
+
min-height: 400px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&-metric-fields {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: baseline;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
column-gap: 8px;
|
|
22
|
+
row-gap: 12px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&-metric-field-single {
|
|
26
|
+
padding-left: 0;
|
|
27
|
+
font-weight: 500;
|
|
28
|
+
cursor: default;
|
|
29
|
+
font-size: 15px;
|
|
30
|
+
color: var(--text-color);
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
color: var(--text-color);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&-indicator-name {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
color: var(--text-color);
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
margin-top: 2px;
|
|
42
|
+
}
|
|
43
|
+
}
|