15
15
*/
16
16
17
17
import React from "react"
18
- import { Chart , ChartAxis , ChartGroup , ChartArea } from "@patternfly/react-charts"
18
+ import { Chart , ChartAxis , ChartArea } from "@patternfly/react-charts"
19
19
import { Log } from "../types"
20
20
21
21
import "../../web/scss/components/Dashboard/Charts.scss"
@@ -42,11 +42,15 @@ const axisStyle = { tickLabels: { fontSize: 9 } }
42
42
const yTickValues = [ 0 , 25 , 50 , 75 , 100 ]
43
43
const yTickLabels = yTickValues . map ( ( _ ) => `${ _ } %` )
44
44
45
+ const styles = {
46
+ memory : { data : { fill : "var(--color-chart-0)" } } ,
47
+ gpu : { data : { fill : "var(--color-chart-1)" } } ,
48
+ }
49
+
45
50
const GPUChart = ( props : Props ) => {
46
51
const { logs } = props
47
- console . log ( generateXValues ( logs ) )
48
52
return (
49
- < div style = { { height : "auto" , width : "100%" } } >
53
+ < div style = { { height : "auto" , width : "100%" , display : "flex" , flexDirection : "column" } } >
50
54
< Chart
51
55
ariaTitle = "GPU Utilization"
52
56
ariaDesc = "Chart showing GPU utilization over time"
@@ -56,28 +60,72 @@ const GPUChart = (props: Props) => {
56
60
minDomain = { { y : 0 } }
57
61
padding = { {
58
62
bottom : 25 ,
59
- left : 50 ,
63
+ left : 60 ,
60
64
right : 5 ,
61
65
top : 10 ,
62
66
} }
63
67
>
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
+ />
65
76
< ChartAxis
66
77
scale = "time"
67
78
style = { axisStyle }
68
79
tickValues = { generateXValues ( logs ) }
69
80
tickFormat = { generateXFormat ( logs ) }
70
81
tickCount = { generateXFormat ( logs ) . length }
71
82
/>
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
+ />
81
129
</ Chart >
82
130
</ div >
83
131
)
0 commit comments