From 5a44fa07fcc91df05b07298bb794e51acca20fbf Mon Sep 17 00:00:00 2001 From: Miao Zhuang <1060950782@163.com> Date: Thu, 2 Mar 2023 13:49:07 +0800 Subject: [PATCH] fix: status label (#218) fix: reduce chart endtime --- src/store/models/service.ts | 2 +- src/utils/metric.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/store/models/service.ts b/src/store/models/service.ts index 1903d4bf..5ba0e36b 100644 --- a/src/store/models/service.ts +++ b/src/store/models/service.ts @@ -103,7 +103,7 @@ export function SereviceModelWrapper(serviceApi) { let _start = start / 1000; let _end = end / 1000; _start = _start - _start % step; - _end = _end + (step - _end % step); + _end -= _end % step; // end time should be less than the current time let query = _query; if (!noSuffix) { if (clusterID) { diff --git a/src/utils/metric.ts b/src/utils/metric.ts index 52bfdaf6..3f6e5c12 100644 --- a/src/utils/metric.ts +++ b/src/utils/metric.ts @@ -260,6 +260,33 @@ export const tooltipTitle = time => export const updateChartByValueType = (options, chartInstance) => { switch (options.valueType) { + case VALUE_TYPE.status: + chartInstance.axis('value', { + label: { + formatter: value => Number(value)?'online':'offline', + }, + }); + chartInstance.tooltip({ + customItems: items => + items.map(item => { + const value = `${Number(item.value)?'online':'offline'}`; + return { + ...item, + value, + }; + }), + showCrosshairs: true, + shared: true, + title: tooltipTitle, + }); + chartInstance.scale({ + value: { + min: 0, + max: options.maxNum || 100, + tickInterval: options.maxNum ? (options.maxNum % 10 + 10) / 5 : 25, + }, + }); + break; case VALUE_TYPE.percentage: chartInstance.axis('value', { label: {