diff --git a/app/static/index.html b/app/static/index.html index f39be2f..b7fcbf5 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -2138,38 +2138,82 @@ return; } - // Add summary information + // Generate colors for namespaces + const colors = ['#0066CC', '#CC0000', '#00CC66', '#FF8800', '#CC00CC', '#666666', '#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7']; + + // Prepare data for Victory chart + const chartData = data.map((item, index) => ({ + x: item.x, + y: item.y, + color: colors[index % colors.length], + podCount: item.podCount || 0, + memoryRequests: item.memoryRequests || 0 + })); + + const chart = React.createElement(Victory.VictoryPie, { + width: container.offsetWidth || 500, + height: 300, + data: chartData, + colorScale: chartData.map(item => item.color), + padding: { top: 20, bottom: 20, left: 20, right: 20 }, + style: { + parent: { + background: '#1A1A1A', + width: '100%', + height: '100%' + }, + labels: { + fill: '#ccc', + fontSize: 11, + fontFamily: 'Red Hat Text, sans-serif' + } + }, + labelComponent: React.createElement(Victory.VictoryLabel, { + style: { + fill: '#ccc', + fontSize: 11, + fontFamily: 'Red Hat Text, sans-serif' + }, + labelPlacement: 'perpendicular', + text: (datum) => { + const cpuCores = datum.y.toFixed(2); + const podCount = datum.podCount; + return `${datum.x}\n${cpuCores} cores\n${podCount} pods`; + } + }), + events: [{ + target: "data", + eventHandlers: { + onMouseOver: () => { + return [{ + target: "labels", + mutation: (props) => { + return { + style: Object.assign({}, props.style, { fill: "#fff", fontSize: 12, fontWeight: "bold" }) + }; + } + }]; + }, + onMouseOut: () => { + return [{ + target: "labels", + mutation: (props) => { + return { + style: Object.assign({}, props.style, { fill: "#ccc", fontSize: 11, fontWeight: "normal" }) + }; + } + }]; + } + } + }] + }); + + // Add summary information below the chart const totalCpu = data.reduce((sum, item) => sum + item.y, 0); const totalPods = data.reduce((sum, item) => sum + (item.podCount || 0), 0); - // Create simple HTML pie chart instead of Victory - const colors = ['#0066CC', '#CC0000', '#00CC66', '#FF8800', '#CC00CC', '#666666', '#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7']; - - let pieHtml = '