@@ -3,7 +3,8 @@ import { IWaterfallGraphProps } from '../types/types';
33import { useWaterfallChart } from './utils' ;
44import styles from './styles.module.scss' ;
55import '../index.css' ;
6- import { DEFAULT_BAR_WIDTH ,
6+ import {
7+ DEFAULT_BAR_WIDTH ,
78 DEFAULT_PIXELS_PER_Y_UNIT ,
89 DEFAULT_SUMMARY_LABEL ,
910 FINAL_SUMMARY_GRAPH_KEY ,
@@ -40,7 +41,7 @@ const WaterFallChart: FC<IWaterfallGraphProps> = (props) => {
4041 const onWrapperDimensionsChange = ( ) : void => {
4142 if ( wrapperRef . current ) {
4243 setWrapperHeight ( wrapperRef ?. current ?. offsetHeight ) ;
43- if ( ! barWidth || barWidth <= 0 ) setBarWidthVal ( calculateBarWidth ( wrapperRef ?. current ?. offsetWidth ) ) ;
44+ if ( ! barWidth || barWidth <= 0 ) setBarWidthVal ( calculateBarWidth ( wrapperRef ?. current ?. offsetWidth ) ) ;
4445 }
4546 } ;
4647
@@ -53,26 +54,26 @@ const WaterFallChart: FC<IWaterfallGraphProps> = (props) => {
5354
5455 const renderSummaryBar = ( ) : JSX . Element => {
5556 const value = Math . abs ( chartElements [ chartElements ?. length - 1 ] ?. cumulativeSum ) ;
56- const barHeight = Math . abs ( ( value / yAxisScale ) * yAxisPixelsPerUnit ) ;
57+ const barHeight = Math . abs ( ( value / yAxisScale ) * yAxisPixelsPerUnit ) ;
5758 const chartElement = {
5859 name : summaryXLabel ,
5960 value,
6061 yVal : yValueForZeroLine - ( value / yAxisScale ) * yAxisPixelsPerUnit ,
6162 cumulativeSum : 0 ,
6263 barHeight : barHeight
63- }
64+ } ;
6465
6566 return (
6667 < rect
6768 key = { FINAL_SUMMARY_GRAPH_KEY }
6869 width = { barWidthVal }
6970 height = { chartElement ?. barHeight }
7071 y = { chartElement ?. yVal }
71- x = { ( 2 * chartElements ?. length + 1 ) * barWidthVal }
72+ x = { ( 2 * chartElements ?. length + 1 ) * barWidthVal }
7273 className = { `${ styles . graphBar } ${ styles . summaryGraphBar } ` }
7374 onClick = { ( ) : void => onChartClick && onChartClick ( chartElement ) }
7475 />
75- )
76+ ) ;
7677 } ;
7778
7879 return (
@@ -105,10 +106,7 @@ const WaterFallChart: FC<IWaterfallGraphProps> = (props) => {
105106 style = { chartElement ?. value >= 0 ? positiveBarStyles : negativeBarStyles }
106107 onClick = { ( ) : void => onChartClick && onChartClick ( chartElement ) }
107108 />
108- { showBridgeLines
109- && ( showFinalSummary
110- || index !== chartElements ?. length - 1 )
111- && (
109+ { showBridgeLines && ( showFinalSummary || index !== chartElements ?. length - 1 ) && (
112110 < line
113111 key = { chartElement ?. name }
114112 className = { styles . bridgeLine }
0 commit comments