File tree Expand file tree Collapse file tree
src/components/LBDashboard/BarGraphs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,31 @@ export function CompareBarGraph({
124124 const tickColor = darkMode ? '#e1e1e1' : '#444' ;
125125 const gridColor = darkMode ? '#3a506b' : '#e0e0e0' ;
126126
127+ const horizontalAxes = getHorizontalAxes ( {
128+ xDomain,
129+ xTicks,
130+ valueFormatter,
131+ tickColor,
132+ xLabel,
133+ nameKey,
134+ yCategoryWidth,
135+ yTickFormatter,
136+ showYAxisTitle,
137+ yLabel,
138+ } ) ;
139+
140+ const verticalAxes = getVerticalAxes (
141+ nameKey ,
142+ tickColor ,
143+ xLabel ,
144+ yDomain ,
145+ yTicks ,
146+ valueFormatter ,
147+ yLabel ,
148+ ) ;
149+
150+ const renderedAxes = isHorizontal ? horizontalAxes : verticalAxes ;
151+
127152 return (
128153 < Card
129154 className = { `${ styles . graphCard } ${ darkMode ? styles . darkCard : '' } ` }
@@ -171,64 +196,16 @@ export function CompareBarGraph({
171196 minHeight : `${ height } px` ,
172197 } }
173198 >
174- { ! data ?. length ? (
175- < div
176- style = { {
177- height,
178- display : 'flex' ,
179- alignItems : 'center' ,
180- justifyContent : 'center' ,
181- color : darkMode ? '#e1e1e1' : '#666' ,
182- } }
183- >
184- No data available
185- </ div >
186- ) : (
199+ { data ?. length ? (
187200 < ResponsiveContainer width = "100%" height = { height } >
188201 < BarChart
189202 data = { data }
190203 layout = { isHorizontal ? 'vertical' : 'horizontal' }
191204 margin = { margins }
192205 >
193206 < 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- } ) ( ) }
207+ { renderedAxes . xAxis }
208+ { renderedAxes . yAxis }
232209
233210 < Tooltip
234211 formatter = { v => [ valueFormatter ( v ) , tooltipLabel || metricLabel || title ] }
@@ -252,6 +229,18 @@ export function CompareBarGraph({
252229 </ Bar >
253230 </ BarChart >
254231 </ ResponsiveContainer >
232+ ) : (
233+ < div
234+ style = { {
235+ height,
236+ display : 'flex' ,
237+ alignItems : 'center' ,
238+ justifyContent : 'center' ,
239+ color : darkMode ? '#e1e1e1' : '#666' ,
240+ } }
241+ >
242+ No data available
243+ </ div >
255244 ) }
256245 </ div >
257246 </ CardBody >
You can’t perform that action at this time.
0 commit comments