From 02430628893500b9e626632f2a1dbc313ec11d09 Mon Sep 17 00:00:00 2001 From: andersonid Date: Wed, 15 Oct 2025 22:34:37 -0300 Subject: [PATCH] fix: improve chart readability with larger fonts, rotated labels, and horizontal bar chart for namespace distribution --- app/static/index.html | 97 ++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 51 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index c2ec37e..d17e72f 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -2379,7 +2379,7 @@ dependentAxis: true, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, tickFormat: (t) => `${t}%` }), @@ -2389,7 +2389,7 @@ tickCount: 8, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, tickFormat: (t) => new Date(t).toLocaleTimeString('pt-BR', { hour: '2-digit', @@ -2468,56 +2468,51 @@ // Calculate total CPU for percentages const totalCpu = data.reduce((sum, item) => sum + item.cpu_requests, 0); - // Create pie chart with labels directly on slices - let pieChartHtml = '
'; + // Sort by CPU usage and take top 10 + const sortedData = data + .sort((a, b) => b.cpu_requests - a.cpu_requests) + .slice(0, 10); + + // Create horizontal bar chart for better readability + let chartHtml = '
'; - // Create pie chart using CSS with labels on slices - pieChartHtml += '
'; - - let currentAngle = 0; - data.forEach((item, index) => { - const percentage = totalCpu > 0 ? (item.cpu_requests / totalCpu) * 100 : 0; - const angle = (percentage / 100) * 360; - const color = colors[index % colors.length]; + sortedData.forEach((item, index) => { + const percentage = data.reduce((sum, d) => sum + d.cpu_requests, 0) > 0 ? + (item.cpu_requests / data.reduce((sum, d) => sum + d.cpu_requests, 0)) * 100 : 0; - if (angle > 0) { - // Calculate label position - const midAngle = currentAngle + (angle / 2); - const labelRadius = 120; - const labelX = 150 + Math.cos((midAngle - 90) * Math.PI / 180) * labelRadius; - const labelY = 150 + Math.sin((midAngle - 90) * Math.PI / 180) * labelRadius; - - pieChartHtml += ` + chartHtml += ` +
+
+ + ${item.namespace} + + + ${percentage.toFixed(1)}% + +
-
${item.namespace}
- `; - currentAngle += angle; - } + width: 100%; + height: 8px; + background: var(--pf-global--BackgroundColor--200); + border-radius: 4px; + overflow: hidden; + "> +
+
+
+ `; }); - pieChartHtml += '
'; - pieChartHtml += '
'; + chartHtml += ''; // Clear container and render chart - container.innerHTML = pieChartHtml; + container.innerHTML = chartHtml; } // 3. Issues by Severity Timeline @@ -2605,7 +2600,7 @@ dependentAxis: true, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } } }), React.createElement(Victory.VictoryAxis, { @@ -2614,7 +2609,7 @@ tickCount: 7, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, tickFormat: (t) => new Date(t).toLocaleDateString('pt-BR', { day: '2-digit', @@ -2703,7 +2698,7 @@ dependentAxis: true, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, tickFormat: (t) => `${t}m` }), @@ -2711,7 +2706,7 @@ key: 'x-axis', style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } } }), React.createElement(Victory.VictoryBar, { @@ -2792,7 +2787,7 @@ dependentAxis: true, style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, tickFormat: (t) => `${t}%` }), @@ -2800,7 +2795,7 @@ key: 'x-axis', style: { axis: { stroke: '#666' }, - tickLabels: { fill: '#ccc', fontSize: 12 } + tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } } }), React.createElement(Victory.VictoryGroup, {