1515 */
1616
1717import React from "react"
18- import { Chart , ChartAxis , ChartGroup , ChartArea } from "@patternfly/react-charts"
18+ import { Chart , ChartAxis , ChartArea } from "@patternfly/react-charts"
1919import { Log } from "../types"
2020
2121import "../../web/scss/components/Dashboard/Charts.scss"
@@ -42,11 +42,15 @@ const axisStyle = { tickLabels: { fontSize: 9 } }
4242const yTickValues = [ 0 , 25 , 50 , 75 , 100 ]
4343const yTickLabels = yTickValues . map ( ( _ ) => `${ _ } %` )
4444
45+ const styles = {
46+ memory : { data : { fill : "var(--color-chart-0)" } } ,
47+ gpu : { data : { fill : "var(--color-chart-1)" } } ,
48+ }
49+
4550const GPUChart = ( props : Props ) => {
4651 const { logs } = props
47- console . log ( generateXValues ( logs ) )
4852 return (
49- < div style = { { height : "auto" , width : "100%" } } >
53+ < div style = { { height : "auto" , width : "100%" , display : "flex" , flexDirection : "column" } } >
5054 < Chart
5155 ariaTitle = "GPU Utilization"
5256 ariaDesc = "Chart showing GPU utilization over time"
@@ -56,28 +60,72 @@ const GPUChart = (props: Props) => {
5660 minDomain = { { y : 0 } }
5761 padding = { {
5862 bottom : 25 ,
59- left : 50 ,
63+ left : 60 ,
6064 right : 5 ,
6165 top : 10 ,
6266 } }
6367 >
64- < ChartAxis dependentAxis showGrid style = { axisStyle } tickValues = { yTickValues } tickFormat = { yTickLabels } />
68+ < ChartAxis
69+ label = "GPU"
70+ dependentAxis
71+ showGrid
72+ style = { axisStyle }
73+ tickValues = { yTickValues }
74+ tickFormat = { yTickLabels }
75+ />
6576 < ChartAxis
6677 scale = "time"
6778 style = { axisStyle }
6879 tickValues = { generateXValues ( logs ) }
6980 tickFormat = { generateXFormat ( logs ) }
7081 tickCount = { generateXFormat ( logs ) . length }
7182 />
72- < ChartGroup >
73- < ChartArea
74- data = { logs . map ( ( log ) => ( {
75- name : log . gpuType ,
76- x : log . timestamp ,
77- y : log . utilizationGPU ,
78- } ) ) }
79- />
80- </ ChartGroup >
83+ < ChartArea
84+ style = { styles . gpu }
85+ data = { logs . map ( ( log ) => ( {
86+ name : log . gpuType ,
87+ x : log . timestamp ,
88+ y : log . utilizationGPU ,
89+ } ) ) }
90+ />
91+ </ Chart >
92+ < Chart
93+ ariaTitle = "GPU Memory Utilization"
94+ ariaDesc = "Chart showing GPU memory utilization over time"
95+ height = { 135 }
96+ width = { 1000 }
97+ maxDomain = { { y : 100 } }
98+ minDomain = { { y : 0 } }
99+ padding = { {
100+ bottom : 25 ,
101+ left : 60 ,
102+ right : 5 ,
103+ top : 10 ,
104+ } }
105+ >
106+ < ChartAxis
107+ label = "Memory"
108+ dependentAxis
109+ showGrid
110+ style = { axisStyle }
111+ tickValues = { yTickValues }
112+ tickFormat = { yTickLabels }
113+ />
114+ < ChartAxis
115+ scale = "time"
116+ style = { axisStyle }
117+ tickValues = { generateXValues ( logs ) }
118+ tickFormat = { generateXFormat ( logs ) }
119+ tickCount = { generateXFormat ( logs ) . length }
120+ />
121+ < ChartArea
122+ style = { styles . memory }
123+ data = { logs . map ( ( log ) => ( {
124+ name : log . gpuType ,
125+ x : log . timestamp ,
126+ y : log . utilizationMemory ,
127+ } ) ) }
128+ />
81129 </ Chart >
82130 </ div >
83131 )
0 commit comments