File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
apps/insights/src/components/PythProDemoPriceChart Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export function PythProDemoPriceChartImpl({
3333 const chartRef = useRef < IChartApi > ( undefined ) ;
3434 const seriesMapRef = useRef < Record < string , ISeriesApi < "Line" > > > ( { } ) ;
3535
36+ /** effects */
3637 useLayoutEffect ( ( ) => {
3738 if ( ! containerRef . current ) return ;
3839
@@ -70,6 +71,26 @@ export function PythProDemoPriceChartImpl({
7071 } ;
7172 } , [ ] ) ;
7273
74+ useLayoutEffect ( ( ) => {
75+ if ( ! chartRef . current || ! containerRef . current ) return ;
76+ const { current : chartApi } = chartRef ;
77+
78+ const o = new ResizeObserver ( ( [ entry ] ) => {
79+ if ( ! entry ) return ;
80+
81+ const {
82+ contentRect : { height, width } ,
83+ } = entry ;
84+ chartApi . resize ( width , height ) ;
85+ } ) ;
86+
87+ o . observe ( containerRef . current ) ;
88+
89+ return ( ) => {
90+ o . disconnect ( ) ;
91+ } ;
92+ } , [ ] ) ;
93+
7394 useEffect ( ( ) => {
7495 if ( ! chartRef . current || ! isAllowedSymbol ( selectedSource ) ) return ;
7596
You can’t perform that action at this time.
0 commit comments