@@ -165,7 +165,8 @@ function KpiTile({ label, value, renderChart }) {
165165 'div' ,
166166 { className : 'kpi-tile' } ,
167167 React . createElement ( 'div' , { className : 'kpi-label' } , label ) ,
168- React . createElement ( 'div' , { className : 'kpi-value' } , value ) ,
168+ value !== undefined && value !== null &&
169+ React . createElement ( 'div' , { className : 'kpi-value' } , value ) ,
169170 renderChart && renderChart ( )
170171 ) ;
171172}
@@ -279,7 +280,7 @@ function HistoricalUsageChart({ monthly }) {
279280 return React . createElement ( 'div' , { className : 'chart-container' } , React . createElement ( 'canvas' , { ref : canvasRef , width : 600 , height : 300 } ) ) ;
280281}
281282
282- function PiConsumptionChart ( { details } ) {
283+ function PiConsumptionChart ( { details, width = 300 , height = 300 , legend = true } ) {
283284 const canvasRef = useRef ( null ) ;
284285 useEffect ( ( ) => {
285286 if ( ! canvasRef . current ) return ;
@@ -323,18 +324,18 @@ function PiConsumptionChart({ details }) {
323324 responsive : false ,
324325 maintainAspectRatio : false ,
325326 plugins : {
326- legend : { position : 'right' }
327+ legend : legend ? { position : 'right' } : { display : false }
327328 }
328329 }
329330 } ) ;
330331
331332 return ( ) => chart . destroy ( ) ;
332- } , [ details ] ) ;
333+ } , [ details , width , height , legend ] ) ;
333334
334335 return React . createElement (
335336 'div' ,
336- { className : 'chart-container' , style : { width : '300px' , height : '300px' } } ,
337- React . createElement ( 'canvas' , { ref : canvasRef , width : 300 , height : 300 } )
337+ { className : 'chart-container' , style : { width : ` ${ width } px` , height : ` ${ height } px` } } ,
338+ React . createElement ( 'canvas' , { ref : canvasRef , width, height } )
338339 ) ;
339340}
340341
@@ -501,6 +502,17 @@ function Summary({ summary, details, daily, monthly }) {
501502 actual : summary . total ,
502503 target : targetRevenue
503504 } )
505+ } ) ,
506+ React . createElement ( KpiTile , {
507+ label : 'Top 10 PIs' ,
508+ value : null ,
509+ renderChart : ( ) =>
510+ React . createElement ( PiConsumptionChart , {
511+ details,
512+ width : 120 ,
513+ height : 120 ,
514+ legend : false
515+ } )
504516 } )
505517 ) ,
506518 React . createElement ( 'h3' , null , 'Top 10 PIs by consumption' ) ,
0 commit comments