mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Cap cpu chart label values to 2 decimal points (#3228)
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
223dadc073
commit
a12fc68242
@ -33,6 +33,10 @@ import { bytesToUnits } from "../../utils";
|
|||||||
import { ThemeStore } from "../../theme.store";
|
import { ThemeStore } from "../../theme.store";
|
||||||
import { getMetricLastPoints } from "../../api/endpoints/metrics.api";
|
import { getMetricLastPoints } from "../../api/endpoints/metrics.api";
|
||||||
|
|
||||||
|
function createLabels(rawLabelData: [string, number | undefined][]): string[] {
|
||||||
|
return rawLabelData.map(([key, value]) => `${key}: ${value?.toFixed(2) || "N/A"}`);
|
||||||
|
}
|
||||||
|
|
||||||
export const ClusterPieCharts = observer(() => {
|
export const ClusterPieCharts = observer(() => {
|
||||||
const renderLimitWarning = () => {
|
const renderLimitWarning = () => {
|
||||||
return (
|
return (
|
||||||
@ -51,7 +55,7 @@ export const ClusterPieCharts = observer(() => {
|
|||||||
const cpuLimitsOverload = cpuLimits > cpuAllocatableCapacity;
|
const cpuLimitsOverload = cpuLimits > cpuAllocatableCapacity;
|
||||||
const memoryLimitsOverload = memoryLimits > memoryAllocatableCapacity;
|
const memoryLimitsOverload = memoryLimits > memoryAllocatableCapacity;
|
||||||
const defaultColor = ThemeStore.getInstance().activeTheme.colors.pieChartDefaultColor;
|
const defaultColor = ThemeStore.getInstance().activeTheme.colors.pieChartDefaultColor;
|
||||||
|
|
||||||
if (!memoryCapacity || !cpuCapacity || !podCapacity || !memoryAllocatableCapacity || !cpuAllocatableCapacity || !podAllocatableCapacity) return null;
|
if (!memoryCapacity || !cpuCapacity || !podCapacity || !memoryAllocatableCapacity || !cpuAllocatableCapacity || !podAllocatableCapacity) return null;
|
||||||
const cpuData: ChartData = {
|
const cpuData: ChartData = {
|
||||||
datasets: [
|
datasets: [
|
||||||
@ -92,13 +96,13 @@ export const ClusterPieCharts = observer(() => {
|
|||||||
label: "Limits"
|
label: "Limits"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
labels: [
|
labels: createLabels([
|
||||||
`Usage: ${cpuUsage ? cpuUsage.toFixed(2) : "N/A"}`,
|
["Usage", cpuUsage],
|
||||||
`Requests: ${cpuRequests ? cpuRequests.toFixed(2) : "N/A"}`,
|
["Requests", cpuRequests],
|
||||||
`Limits: ${cpuLimits ? cpuLimits.toFixed(2) : "N/A"}`,
|
["Limits", cpuLimits],
|
||||||
`Allocatable Capacity: ${cpuAllocatableCapacity || "N/A"}`,
|
["Allocatable Capacity", cpuAllocatableCapacity],
|
||||||
`Capacity: ${cpuCapacity || "N/A"}`
|
["Capacity", cpuCapacity],
|
||||||
]
|
]),
|
||||||
};
|
};
|
||||||
const memoryData: ChartData = {
|
const memoryData: ChartData = {
|
||||||
datasets: [
|
datasets: [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user