@@ -116,7 +116,6 @@ export function CompareBarGraph({
116116 height = 420 ,
117117 yCategoryWidth = 70 ,
118118 margins = { top : 16 , right : 20 , bottom : 46 , left : 0 } ,
119- maxBars,
120119 showYAxisTitle = true ,
121120 yTickFormatter,
122121 darkMode = false ,
@@ -165,75 +164,95 @@ export function CompareBarGraph({
165164 </ div >
166165
167166 { /* chart */ }
168- < div className = { styles . graphCanvas } >
169- < ResponsiveContainer width = "100%" height = { height } >
170- < BarChart
171- data = { data }
172- layout = { isHorizontal ? 'vertical' : 'horizontal' }
173- margin = { margins }
167+ < div
168+ className = { styles . graphCanvas }
169+ style = { {
170+ width : '100%' ,
171+ minHeight : `${ height } px` ,
172+ } }
173+ >
174+ { ! data ?. length ? (
175+ < div
176+ style = { {
177+ height,
178+ display : 'flex' ,
179+ alignItems : 'center' ,
180+ justifyContent : 'center' ,
181+ color : darkMode ? '#e1e1e1' : '#666' ,
182+ } }
174183 >
175- < CartesianGrid strokeDasharray = "3 3" stroke = { gridColor } />
176- { isHorizontal
177- ? ( ( ) => {
178- const axes = getHorizontalAxes ( {
179- xDomain,
180- xTicks,
181- valueFormatter,
182- tickColor,
183- xLabel,
184- nameKey,
185- yCategoryWidth,
186- yTickFormatter,
187- showYAxisTitle,
188- yLabel,
189- } ) ;
190- return (
191- < >
192- { axes . xAxis }
193- { axes . yAxis }
194- </ >
195- ) ;
196- } ) ( )
197- : ( ( ) => {
198- const axes = getVerticalAxes (
199- nameKey ,
200- tickColor ,
201- xLabel ,
202- yDomain ,
203- yTicks ,
204- valueFormatter ,
205- yLabel ,
206- ) ;
207- return (
208- < >
209- { axes . xAxis }
210- { axes . yAxis }
211- </ >
212- ) ;
213- } ) ( ) }
184+ No data available
185+ </ div >
186+ ) : (
187+ < ResponsiveContainer width = "100%" height = { height } >
188+ < BarChart
189+ data = { data }
190+ layout = { isHorizontal ? 'vertical' : 'horizontal' }
191+ margin = { margins }
192+ >
193+ < CartesianGrid strokeDasharray = "3 3" stroke = { gridColor } />
194+ { isHorizontal
195+ ? ( ( ) => {
196+ const axes = getHorizontalAxes ( {
197+ xDomain,
198+ xTicks,
199+ valueFormatter,
200+ tickColor,
201+ xLabel,
202+ nameKey,
203+ yCategoryWidth,
204+ yTickFormatter,
205+ showYAxisTitle,
206+ yLabel,
207+ } ) ;
208+ return (
209+ < >
210+ { axes . xAxis }
211+ { axes . yAxis }
212+ </ >
213+ ) ;
214+ } ) ( )
215+ : ( ( ) => {
216+ const axes = getVerticalAxes (
217+ nameKey ,
218+ tickColor ,
219+ xLabel ,
220+ yDomain ,
221+ yTicks ,
222+ valueFormatter ,
223+ yLabel ,
224+ ) ;
225+ return (
226+ < >
227+ { axes . xAxis }
228+ { axes . yAxis }
229+ </ >
230+ ) ;
231+ } ) ( ) }
214232
215- < Tooltip
216- formatter = { v => [ valueFormatter ( v ) , tooltipLabel || metricLabel || title ] }
217- labelFormatter = { lbl => `${ lbl } ` }
218- contentStyle = { {
219- background : darkMode ? '#1c2541' : '#fff' ,
220- border : `1px solid ${ darkMode ? '#3a506b' : '#ccc' } ` ,
221- color : darkMode ? '#e1e1e1' : '#333' ,
222- } }
223- itemStyle = { { color : darkMode ? '#e1e1e1' : '#333' } }
224- labelStyle = { { color : darkMode ? '#e1e1e1' : '#333' , fontWeight : 600 } }
225- />
226- < Bar dataKey = { valueKey } radius = { [ 4 , 4 , 4 , 4 ] } fill = { barColor } barSize = { barSize } >
227- < LabelList
228- dataKey = { valueKey }
229- position = { isHorizontal ? 'right' : 'top' }
230- formatter = { valueFormatter }
231- style = { { fontSize : 15 , fontWeight : 600 } }
232- offset = { 8 }
233+ < Tooltip
234+ formatter = { v => [ valueFormatter ( v ) , tooltipLabel || metricLabel || title ] }
235+ labelFormatter = { lbl => `${ lbl } ` }
236+ contentStyle = { {
237+ background : darkMode ? '#1c2541' : '#fff' ,
238+ border : `1px solid ${ darkMode ? '#3a506b' : '#ccc' } ` ,
239+ color : darkMode ? '#e1e1e1' : '#333' ,
240+ } }
241+ itemStyle = { { color : darkMode ? '#e1e1e1' : '#333' } }
242+ labelStyle = { { color : darkMode ? '#e1e1e1' : '#333' , fontWeight : 600 } }
233243 />
234- </ Bar >
235- </ BarChart >
236- </ ResponsiveContainer >
244+ < Bar dataKey = { valueKey } radius = { [ 4 , 4 , 4 , 4 ] } fill = { barColor } barSize = { barSize } >
245+ < LabelList
246+ dataKey = { valueKey }
247+ position = { isHorizontal ? 'right' : 'top' }
248+ formatter = { valueFormatter }
249+ style = { { fontSize : 15 , fontWeight : 600 } }
250+ offset = { 8 }
251+ />
252+ </ Bar >
253+ </ BarChart >
254+ </ ResponsiveContainer >
255+ ) }
237256 </ div >
238257 </ CardBody >
239258 </ Card >
@@ -272,7 +291,6 @@ CompareBarGraph.propTypes = {
272291 bottom : PropTypes . number ,
273292 left : PropTypes . number ,
274293 } ) ,
275- maxBars : PropTypes . number ,
276294 showYAxisTitle : PropTypes . bool ,
277295 yTickFormatter : PropTypes . func ,
278296 darkMode : PropTypes . bool ,
0 commit comments