diff --git a/src/components/DashboardCard/LineCard.tsx b/src/components/DashboardCard/LineCard.tsx index 769c9e51..ff950084 100644 --- a/src/components/DashboardCard/LineCard.tsx +++ b/src/components/DashboardCard/LineCard.tsx @@ -21,10 +21,10 @@ function LineCard(props: IProps) { if (!loading && chartRef.current) { updateChart(); } - }, [loading, chartRef.current]); + }, [loading, chartRef.current]); useEffect(() => { - if (baseLine != undefined && chartRef.current) { + if (chartRef.current) { chartRef.current.updateBaseline(baseLine); } }, [baseLine, chartRef.current]); @@ -37,6 +37,14 @@ function LineCard(props: IProps) { updateChart(); }; + useEffect(() => { + chartRef.current?.configDetailChart({ + valueType, + isCard: true, + }); + updateChart(); + }, [valueType]); + const updateChart = () => { const realRange = data.length > 0 ? (data[data.length - 1].time - data[0].time) : 0; const gap = Math.floor(realRange / 10); // 10 ticks max @@ -62,7 +70,7 @@ function LineCard(props: IProps) { loading ? : ( chartRef.current = ref} + ref={chartRef} options={{ padding: [20, 20, 60, 6 * maxNumLen + 30] }} />) ); diff --git a/src/pages/ServiceManage/Overview/index.tsx b/src/pages/ServiceManage/Overview/index.tsx index 2073a043..036abbc1 100644 --- a/src/pages/ServiceManage/Overview/index.tsx +++ b/src/pages/ServiceManage/Overview/index.tsx @@ -13,10 +13,9 @@ import { getVersionFeatures } from '@/utils/versionFeature'; import Modal from '@/components/Modal'; import { IDispatch, IRootState } from '@/store'; import { formatVersion } from '@/utils/dashboard'; +import { isCommunityVersion } from '@/utils'; import styles from './index.module.less'; -import { isCommunityVersion } from '@/utils'; -import { ICluster } from '@base/utils/interface'; const mapDispatch: any = (dispatch: IDispatch) => ({ asyncUseSpaces: dispatch.nebula.asyncUseSpaces, @@ -41,7 +40,7 @@ interface IProps ReturnType, RouteComponentProps { baseRouter?: string; - cluster?: ICluster; + cluster?: any; } const OverviewCardHeader = (props: IHaderProps) => { diff --git a/src/utils/metric.ts b/src/utils/metric.ts index ccba311c..ed4267d1 100644 --- a/src/utils/metric.ts +++ b/src/utils/metric.ts @@ -111,16 +111,19 @@ export const calcMetricInfo = (rawMetric: string) => { } const calcServiceMetricValueType = (metricName: string): VALUE_TYPE => { - let valueType = VALUE_TYPE.number; - const valueTypes = Object.keys(ServiceMetricValueTypeMap) as VALUE_TYPE[]; - for (let i = 0; i < valueTypes.length; i++) { - const curValueType = valueTypes[i]; - if (ServiceMetricValueTypeMap[curValueType].includes(metricName)) { - valueType = curValueType as VALUE_TYPE; - break; - } + if (metricName.includes('num')) { + return VALUE_TYPE.number; + } + if (metricName.includes('latency')) { + return VALUE_TYPE.latency; } - return valueType; + if (metricName.includes('bytes')) { + return VALUE_TYPE.byte; + } + if (metricName.includes('seconds')) { + return VALUE_TYPE.byteSecond; + } + return VALUE_TYPE.number; } export const filterServiceMetrics = (payload: { @@ -216,11 +219,11 @@ export const RawServiceMetrics = [ "write_bytes_total", ] -export const ServiceMetricValueTypeMap = { - [VALUE_TYPE.byte]: ["write_bytes_total", "memory_bytes_gauge", "read_bytes_total"], - [VALUE_TYPE.byteSecond]: [], - [VALUE_TYPE.numberSecond]: ["cpu_seconds_total"] -} +// export const ServiceMetricValueTypeMap = { +// [VALUE_TYPE.byte]: ["write_bytes_total", "memory_bytes_gauge", "read_bytes_total"], +// [VALUE_TYPE.byteSecond]: [], +// [VALUE_TYPE.numberSecond]: ["cpu_seconds_total"], +// } export const getQueryMap = (metricItem: IServiceMetricItem) => { const res = {};