mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 11:07:06 +00:00
(feature)(webapp) modify view field (#732)
This commit is contained in:
@@ -1,20 +1,26 @@
|
|||||||
import { CHART_BLUE_COLOR, CHART_SECONDARY_COLOR, PREFIX_CLS } from '../../../common/constants';
|
import { CHART_BLUE_COLOR, CHART_SECONDARY_COLOR, PREFIX_CLS } from '../../../common/constants';
|
||||||
import { MsgDataType } from '../../../common/type';
|
import { MsgDataType } from '../../../common/type';
|
||||||
import { getChartLightenColor, getFormattedValue } from '../../../utils/utils';
|
import {
|
||||||
|
formatByDecimalPlaces,
|
||||||
|
getChartLightenColor,
|
||||||
|
getFormattedValue,
|
||||||
|
} from '../../../utils/utils';
|
||||||
import type { ECharts } from 'echarts';
|
import type { ECharts } from 'echarts';
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import NoPermissionChart from '../NoPermissionChart';
|
import NoPermissionChart from '../NoPermissionChart';
|
||||||
|
import { ColumnType } from '../../../common/type';
|
||||||
import { Spin } from 'antd';
|
import { Spin } from 'antd';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
data: MsgDataType;
|
data: MsgDataType;
|
||||||
triggerResize?: boolean;
|
triggerResize?: boolean;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
|
metricField: ColumnType;
|
||||||
onApplyAuth?: (model: string) => void;
|
onApplyAuth?: (model: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const BarChart: React.FC<Props> = ({ data, triggerResize, loading, onApplyAuth }) => {
|
const BarChart: React.FC<Props> = ({ data, triggerResize, loading, metricField, onApplyAuth }) => {
|
||||||
const chartRef = useRef<any>();
|
const chartRef = useRef<any>();
|
||||||
const [instance, setInstance] = useState<ECharts>();
|
const [instance, setInstance] = useState<ECharts>();
|
||||||
|
|
||||||
@@ -70,7 +76,11 @@ const BarChart: React.FC<Props> = ({ data, triggerResize, loading, onApplyAuth }
|
|||||||
},
|
},
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
formatter: function (value: any) {
|
formatter: function (value: any) {
|
||||||
return value === 0 ? 0 : getFormattedValue(value);
|
return value === 0
|
||||||
|
? 0
|
||||||
|
: metricField.dataFormatType === 'percent'
|
||||||
|
? `${formatByDecimalPlaces(value, metricField.dataFormat?.decimalPlaces || 2)}%`
|
||||||
|
: getFormattedValue(value);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -85,9 +95,17 @@ const BarChart: React.FC<Props> = ({ data, triggerResize, loading, onApplyAuth }
|
|||||||
item.marker
|
item.marker
|
||||||
} <span style="display: inline-block; width: 70px; margin-right: 12px;">${
|
} <span style="display: inline-block; width: 70px; margin-right: 12px;">${
|
||||||
item.seriesName
|
item.seriesName
|
||||||
}</span><span style="display: inline-block; width: 90px; text-align: right; font-weight: 500;">${getFormattedValue(
|
}</span><span style="display: inline-block; width: 90px; text-align: right; font-weight: 500;">${
|
||||||
item.value
|
item.value === ''
|
||||||
)}</span></div>`
|
? '-'
|
||||||
|
: metricField.dataFormatType === 'percent' ||
|
||||||
|
metricField.dataFormatType === 'decimal'
|
||||||
|
? `${formatByDecimalPlaces(
|
||||||
|
item.value,
|
||||||
|
metricField.dataFormat?.decimalPlaces || 2
|
||||||
|
)}${metricField.dataFormatType === 'percent' ? '%' : ''}`
|
||||||
|
: getFormattedValue(item.value)
|
||||||
|
}</span></div>`
|
||||||
)
|
)
|
||||||
.join('');
|
.join('');
|
||||||
return `${param.name}<br />${valueLabels}`;
|
return `${param.name}<br />${valueLabels}`;
|
||||||
@@ -115,7 +133,11 @@ const BarChart: React.FC<Props> = ({ data, triggerResize, loading, onApplyAuth }
|
|||||||
show: true,
|
show: true,
|
||||||
position: 'top',
|
position: 'top',
|
||||||
formatter: function ({ value }: any) {
|
formatter: function ({ value }: any) {
|
||||||
return getFormattedValue(value);
|
return value === 0
|
||||||
|
? 0
|
||||||
|
: metricField.dataFormatType === 'percent'
|
||||||
|
? `${formatByDecimalPlaces(value, metricField.dataFormat?.decimalPlaces || 2)}%`
|
||||||
|
: getFormattedValue(value);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: data.map(item => {
|
data: data.map(item => {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ const WebPage: React.FC<Props> = ({ id, data }) => {
|
|||||||
const { msgId, height } = payload;
|
const { msgId, height } = payload;
|
||||||
if (`${msgId}` === `${id}`) {
|
if (`${msgId}` === `${id}`) {
|
||||||
setHeight(height);
|
setHeight(height);
|
||||||
// updateMessageContainerScroll();
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,13 +128,14 @@ const ChatMsg: React.FC<Props> = ({ queryId, data, chartIndex, triggerResize })
|
|||||||
if (
|
if (
|
||||||
categoryField?.length > 0 &&
|
categoryField?.length > 0 &&
|
||||||
metricFields?.length > 0 &&
|
metricFields?.length > 0 &&
|
||||||
(isMobile ? dataSource?.length <= 20 : dataSource?.length <= 50)
|
(isMobile ? dataSource?.length <= 5 : dataSource?.length <= 50)
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<Bar
|
<Bar
|
||||||
data={{ ...data, queryColumns: columns, queryResults: dataSource }}
|
data={{ ...data, queryColumns: columns, queryResults: dataSource }}
|
||||||
triggerResize={triggerResize}
|
triggerResize={triggerResize}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
metricField={metricFields[0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
FunctionParamFormItemType,
|
FunctionParamFormItemType,
|
||||||
PluginTypeEnum,
|
PluginTypeEnum,
|
||||||
} from './type';
|
} from './type';
|
||||||
import { getLeafList, traverseTree, uuid } from '@/utils/utils';
|
import { traverseTree, uuid } from '@/utils/utils';
|
||||||
import styles from './style.less';
|
import styles from './style.less';
|
||||||
import { PLUGIN_TYPE_MAP } from './constants';
|
import { PLUGIN_TYPE_MAP } from './constants';
|
||||||
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
|
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getLeafList } from '@/utils/utils';
|
import { getLeafNodes } from '@/utils/utils';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { Button, Input, message, Popconfirm, Select, Table, Tag } from 'antd';
|
import { Button, Input, message, Popconfirm, Select, Table, Tag } from 'antd';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
@@ -24,7 +24,7 @@ const PluginManage = () => {
|
|||||||
|
|
||||||
const initModelList = async () => {
|
const initModelList = async () => {
|
||||||
const res = await getModelList();
|
const res = await getModelList();
|
||||||
setModelList(getLeafList(res.data));
|
setModelList(getLeafNodes(res.data));
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateData = async (filters?: any) => {
|
const updateData = async (filters?: any) => {
|
||||||
@@ -68,7 +68,7 @@ const PluginManage = () => {
|
|||||||
return value ? (
|
return value ? (
|
||||||
<div className={styles.modelColumn}>
|
<div className={styles.modelColumn}>
|
||||||
{value.map((id) => {
|
{value.map((id) => {
|
||||||
const name = modelList.find((model) => model.id === +id)?.name;
|
const name = modelList.find((model) => model.id === id)?.name;
|
||||||
return name ? <Tag key={id}>{name}</Tag> : null;
|
return name ? <Tag key={id}>{name}</Tag> : null;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ export const getFormattedValueData = (value: number | string, remainZero?: boole
|
|||||||
return `${formattedValue}${unit === NumericUnit.None ? '' : unit}`;
|
return `${formattedValue}${unit === NumericUnit.None ? '' : unit}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getLeafNodes(treeNodes: any[]): any[] {
|
export function getLeafNodes(treeNodes: any[]): any[] {
|
||||||
const leafNodes: any[] = [];
|
const leafNodes: any[] = [];
|
||||||
|
|
||||||
function traverse(node: any) {
|
function traverse(node: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user