Split overview charts into discrete components

This commit is contained in:
Joshua Boniface 2025-02-28 20:24:58 -05:00
parent 9e14502bc2
commit 97de6bda82
10 changed files with 1095 additions and 344 deletions

View File

@ -143,72 +143,33 @@
<div v-show="sections.graphs" class="section-content-wrapper">
<div class="section-content">
<div class="graphs-row">
<!-- Health Card -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0 metric-label">Cluster Health</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ clusterData.cluster_health?.health || 0 }}%
</h4>
</div>
<div class="chart-wrapper">
<Line :data="healthChartData" :options="healthChartOptions" />
</div>
</div>
</div>
<!-- Health Chart -->
<HealthChart
title="Cluster Health"
:value="clusterHealth"
:chart-data="healthChartData"
/>
<!-- CPU Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">CPU Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.cpu.data[metricsData.cpu.data.length - 1] || 0 }}%
</h4>
</div>
<div class="chart-wrapper">
<Line :data="cpuChartData" :options="chartOptions" />
</div>
</div>
</div>
<CPUChart
title="CPU Utilization"
:value="cpuUtilization"
:chart-data="cpuChartData"
/>
<!-- Memory Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Memory Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.memory.data[metricsData.memory.data.length - 1] || 0 }}%
</h4>
</div>
<Line :data="memoryChartData" :options="chartOptions" />
</div>
</div>
<MemoryChart
title="Memory Utilization"
:value="memoryUtilization"
:chart-data="memoryChartData"
/>
<!-- Storage Chart -->
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">Storage Utilization</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">
{{ metricsData.storage?.data[metricsData.storage?.data.length - 1] || 0 }}%
</h4>
</div>
<Line :data="storageChartData" :options="chartOptions" />
</div>
</div>
<StorageChart
title="Storage Utilization"
:value="storageUtilization"
:chart-data="storageChartData"
/>
</div>
</div>
<div class="toggle-column expanded">
@ -368,6 +329,10 @@ import {
Filler
} from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
import CPUChart from './charts/CPUChart.vue';
import MemoryChart from './charts/MemoryChart.vue';
import StorageChart from './charts/StorageChart.vue';
import HealthChart from './charts/HealthChart.vue';
// Register Chart.js components
ChartJS.register(
@ -452,59 +417,45 @@ const getDeltaClass = (delta, msg) => {
return 'delta-info';
};
const healthChartData = computed(() => {
return {
// Simplified chart data for the new chart components
const healthChartData = computed(() => ({
labels: props.metricsData.health.labels,
datasets: [{
data: props.metricsData.health.data,
fill: true,
segment: {
borderColor: (ctx) => {
console.log('Context:', ctx);
console.log('Maintenance data:', props.metricsData.maintenance?.data);
console.log('Available indices:', ctx.p0?.parsed?.x, ctx.p1?.parsed?.x);
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.p0.parsed.x];
console.log('Point', ctx.p0.parsed.x, 'Maintenance:', maintenanceAtPoint);
if (maintenanceAtPoint === true) {
console.log('Using blue color for maintenance');
return 'rgba(13, 110, 253, 0.2)';
}
const value = ctx.p1.parsed.y;
console.log('Using health-based color:', value);
if (value > 90) return 'rgba(40, 167, 69, 0.2)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.2)'; // Yellow
return 'rgba(220, 53, 69, 0.2)'; // Red
},
backgroundColor: (ctx) => {
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.p0.parsed.x];
if (maintenanceAtPoint === true) {
return 'rgba(13, 110, 253, 0.1)';
}
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.1)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.1)'; // Yellow
return 'rgba(220, 53, 69, 0.1)'; // Red
}
},
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)', // Light background for all points
pointBorderColor: (ctx) => {
const maintenanceAtPoint = props.metricsData.maintenance?.data[ctx.dataIndex];
if (maintenanceAtPoint === true) return 'rgba(13, 110, 253, 0.5)'; // Blue for maintenance
if (!ctx.raw) return 'rgba(0, 0, 0, 0.2)';
const value = ctx.raw;
if (value > 90) return 'rgba(40, 167, 69, 0.5)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.5)'; // Yellow
return 'rgba(220, 53, 69, 0.5)'; // Red
},
pointBorderWidth: 1.5
}]
};
});
data: props.metricsData.health.data
}));
const cpuChartData = computed(() => ({
labels: props.metricsData.cpu.labels,
data: props.metricsData.cpu.data
}));
const memoryChartData = computed(() => ({
labels: props.metricsData.memory.labels,
data: props.metricsData.memory.data
}));
const storageChartData = computed(() => ({
labels: props.metricsData.storage?.labels || [],
data: props.metricsData.storage?.data || []
}));
// Current values for the charts
const clusterHealth = computed(() =>
props.clusterData.cluster_health?.health || 0
);
const cpuUtilization = computed(() =>
props.metricsData.cpu.data[props.metricsData.cpu.data.length - 1] || 0
);
const memoryUtilization = computed(() =>
props.metricsData.memory.data[props.metricsData.memory.data.length - 1] || 0
);
const storageUtilization = computed(() =>
props.metricsData.storage?.data[props.metricsData.storage?.data.length - 1] || 0
);
// Health chart options for the threshold lines
const healthChartOptions = {
responsive: true,
maintainAspectRatio: false,
@ -568,103 +519,6 @@ const healthChartOptions = {
}
};
const cpuChartData = computed(() => ({
labels: props.metricsData.cpu.labels,
datasets: [{
label: 'CPU',
data: props.metricsData.cpu.data,
borderColor: 'rgb(75, 192, 192)',
fill: true,
backgroundColor: 'rgba(75, 192, 192, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(75, 192, 192, 0.5)',
pointBorderWidth: 1.5
}]
}));
const memoryChartData = computed(() => ({
labels: props.metricsData.memory.labels,
datasets: [{
label: 'Memory',
data: props.metricsData.memory.data,
borderColor: 'rgb(153, 102, 255)',
fill: true,
backgroundColor: 'rgba(153, 102, 255, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(153, 102, 255, 0.5)',
pointBorderWidth: 1.5
}]
}));
const storageChartData = computed(() => ({
labels: props.metricsData.storage?.labels || [],
datasets: [{
label: 'Storage',
data: props.metricsData.storage?.data || [],
borderColor: 'rgb(255, 159, 64)',
fill: true,
backgroundColor: 'rgba(255, 159, 64, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(255, 159, 64, 0.5)',
pointBorderWidth: 1.5
}]
}));
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0, /* Disable resize animation */
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize(); /* Force resize on container change */
}
};
// Helper function to group objects by state
const groupByState = (items, stateExtractor) => {
const groups = {};
@ -1394,8 +1248,13 @@ const getMessageText = (msg) => {
.chart-wrapper {
position: relative;
width: 100%;
height: 100%;
min-width: 0;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
/* Add new style for full-width messages */

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-cpu"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'CPU Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'CPU',
data: props.chartData.data || [],
borderColor: 'rgb(75, 192, 192)',
fill: true,
backgroundColor: 'rgba(75, 192, 192, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(75, 192, 192, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-cpu {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,291 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-health"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
import annotationPlugin from 'chartjs-plugin-annotation';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler,
annotationPlugin
);
const props = defineProps({
title: {
type: String,
default: 'Health'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
},
annotation: {
annotations: {
criticalLine: {
type: 'line',
yMin: 50,
yMax: 50,
borderColor: 'rgba(220, 53, 69, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
},
warningLine: {
type: 'line',
yMin: 90,
yMax: 90,
borderColor: 'rgba(255, 193, 7, 0.5)',
borderWidth: 1,
borderDash: [5, 5]
}
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
// Helper function to get health color based on value
const getHealthColor = (value) => {
if (value > 90) {
return {
border: 'rgba(40, 167, 69, 0.8)', // Green
background: 'rgba(40, 167, 69, 0.1)'
};
} else if (value > 50) {
return {
border: 'rgba(255, 193, 7, 0.8)', // Yellow
background: 'rgba(255, 193, 7, 0.1)'
};
} else {
return {
border: 'rgba(220, 53, 69, 0.8)', // Red
background: 'rgba(220, 53, 69, 0.1)'
};
}
};
const formattedChartData = computed(() => {
const labels = props.chartData.labels || [];
const data = props.chartData.data || [];
// For single value or empty data
if (data.length <= 1) {
const value = data.length === 1 ? data[0] : props.value;
const color = getHealthColor(value);
return {
labels: labels.length ? labels : ['Health'],
datasets: [{
label: 'Health',
data: data.length ? data : [value],
borderColor: color.border,
backgroundColor: color.background,
fill: true,
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: color.border,
pointBorderWidth: 1.5
}]
};
}
// For historical data with multiple values
return {
labels,
datasets: [{
label: 'Health',
data,
segment: {
borderColor: ctx => {
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.8)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.8)'; // Yellow
return 'rgba(220, 53, 69, 0.8)'; // Red
},
backgroundColor: ctx => {
const value = ctx.p1.parsed.y;
if (value > 90) return 'rgba(40, 167, 69, 0.1)'; // Green
if (value > 50) return 'rgba(255, 193, 7, 0.1)'; // Yellow
return 'rgba(220, 53, 69, 0.1)'; // Red
}
},
fill: true,
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: function(context) {
const index = context.dataIndex;
const value = context.dataset.data[index];
return getHealthColor(value).border;
},
pointBorderWidth: 1.5
}]
};
});
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-health {
background: white;
border: none;
}
/* Add these styles to match the original design */
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-memory"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'Memory Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'Memory',
data: props.chartData.data || [],
borderColor: 'rgb(153, 102, 255)',
fill: true,
backgroundColor: 'rgba(153, 102, 255, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(153, 102, 255, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-memory {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -0,0 +1,202 @@
<template>
<div class="metric-card">
<div class="card-header">
<h6 class="card-title mb-0">
<span class="metric-label">{{ title }}</span>
</h6>
</div>
<div class="card-body">
<div class="metric-percentage">
<h4 class="metric-value">{{ value }}%</h4>
</div>
<div class="chart-wrapper">
<Line
:data="formattedChartData"
:options="chartOptions"
class="chart-storage"
/>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { Line } from 'vue-chartjs';
import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler } from 'chart.js';
// Register Chart.js components
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
LineElement,
Title,
Tooltip,
Legend,
Filler
);
const props = defineProps({
title: {
type: String,
default: 'Storage Utilization'
},
value: {
type: Number,
default: 0
},
chartData: {
type: Object,
default: () => ({ labels: [], data: [] })
}
});
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
clip: false,
resizeDelay: 0,
responsiveAnimationDuration: 0,
plugins: {
legend: {
display: false
},
tooltip: {
callbacks: {
label: (context) => `${context.parsed.y}%`
}
}
},
scales: {
x: {
display: false,
grid: {
display: false
}
},
y: {
display: false,
grid: {
display: false
},
min: 0,
max: 100
}
},
animation: false,
interaction: {
enabled: true,
mode: 'nearest',
intersect: false
},
onResize: (chart, size) => {
chart.resize();
}
};
const formattedChartData = computed(() => ({
labels: props.chartData.labels || [],
datasets: [{
label: 'Storage',
data: props.chartData.data || [],
borderColor: 'rgb(255, 159, 64)',
fill: true,
backgroundColor: 'rgba(255, 159, 64, 0.1)',
borderWidth: 1.5,
tension: 0.4,
pointRadius: 0,
pointHoverRadius: 4,
pointBackgroundColor: 'rgba(255, 255, 255, 0.8)',
pointBorderColor: 'rgba(255, 159, 64, 0.5)',
pointBorderWidth: 1.5
}]
}));
</script>
<style scoped>
.chart-wrapper {
position: relative;
width: 100%;
height: 160px;
min-height: 160px;
overflow: hidden;
border: none;
border-radius: 0;
background-color: white;
margin: 0;
}
.metric-percentage {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.8);
padding: 0.25rem 0.75rem;
border-radius: 0.5rem;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
z-index: 2;
}
.metric-percentage .metric-value {
font-size: 2.5rem;
font-weight: 500;
color: #333;
line-height: 1;
margin: 0;
text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.chart-storage {
background: white;
border: none;
}
.metric-card {
min-width: 180px;
background: white;
border: 1px solid rgba(0,0,0,0.125);
border-radius: 0.25rem;
height: 100%;
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;
overflow: hidden;
}
.metric-card .card-header {
background-color: rgba(0, 0, 0, 0.03);
padding: 0.5rem;
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
height: 38px;
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h6 {
font-size: 0.95rem;
font-weight: 600;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0;
}
.metric-card .card-body {
flex: 1;
padding: 0.5rem;
display: flex;
flex-direction: column;
position: relative;
width: 100%;
overflow: visible;
}
.metric-label {
color: #495057;
font-weight: 600;
}
</style>

View File

@ -170,35 +170,31 @@
<div class="section-content">
<div class="graphs-row">
<!-- Health Chart -->
<MetricsChart
<HealthChart
title="Node Health"
:value="selectedNodeData.health || 0"
:chart-data="nodeHealthChartData"
chart-type="health"
/>
<!-- CPU Utilization Chart -->
<MetricsChart
<CPUChart
title="CPU Utilization"
:value="calculateCpuUtilization(selectedNodeData)"
:chart-data="nodeCpuChartData"
chart-type="cpu"
/>
<!-- Memory Utilization Chart -->
<MetricsChart
<MemoryChart
title="Memory Utilization"
:value="calculateMemoryUtilization(selectedNodeData)"
:chart-data="nodeMemoryChartData"
chart-type="memory"
/>
<!-- Allocated Memory Chart -->
<MetricsChart
<StorageChart
title="Allocated Memory"
:value="calculateAllocatedMemory(selectedNodeData)"
:chart-data="nodeAllocatedMemoryChartData"
chart-type="storage"
/>
</div>
</div>
@ -309,7 +305,10 @@
<script setup>
import { ref, computed, onMounted, watch, nextTick, onUnmounted } from 'vue';
import PageTitle from '../components/PageTitle.vue';
import MetricsChart from '../components/MetricsCharts.vue';
import CPUChart from '../components/charts/CPUChart.vue';
import MemoryChart from '../components/charts/MemoryChart.vue';
import StorageChart from '../components/charts/StorageChart.vue';
import HealthChart from '../components/charts/HealthChart.vue';
// Implement formatBytes function directly
function formatBytes(bytes, decimals = 2) {
@ -453,10 +452,8 @@ const calculateAllocatedMemory = (nodeData) => {
return Math.round(utilization);
};
// Prepare chart data for MetricsChart component
// Prepare chart data for the node
const nodeHealthChartData = computed(() => {
if (!selectedNodeData.value) return { labels: [], data: [] };
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];
@ -475,8 +472,6 @@ const nodeHealthChartData = computed(() => {
});
const nodeCpuChartData = computed(() => {
if (!selectedNodeData.value) return { labels: [], data: [] };
// Get node metrics history if available
const nodeMetrics = props.metricsData.nodes?.[selectedNodeData.value.name];