@@ -26,6 +26,7 @@ interface IDeclarativeChartProps {
2626 width ?: number ;
2727 height ?: number ;
2828 isReversedOrder ?: boolean ;
29+ isRTL ?: boolean ;
2930}
3031
3132
@@ -85,7 +86,7 @@ const schemasData = requireContext.keys().map((fileName: string) => ({
8586
8687const textFieldStyles : Partial < ITextFieldStyles > = { root : { maxWidth : 300 } } ;
8788
88- const DeclarativeChartBasicExample : React . FC < IDeclarativeChartProps > = ( { width, height, isReversedOrder = false } ) => {
89+ const DeclarativeChartBasicExample : React . FC < IDeclarativeChartProps > = ( { width, height, isReversedOrder = false , isRTL = false } ) => {
8990 const savedOptionStr = getSelection ( SCHEMA_KEY , SCHEMA_KEY_DEFAULT ) ;
9091 const savedOption = parseInt ( savedOptionStr , 10 ) - 1 ; // To handle 0 based index
9192 const savedFileName = `data_${ savedOptionStr } .json` ;
@@ -128,22 +129,16 @@ const DeclarativeChartBasicExample: React.FC<IDeclarativeChartProps> = ({ width,
128129 if ( ! height ) return ;
129130
130131 const applyHeightToCharts = ( ) => {
131- // Find all chart containers
132- const containers = [
133- document . querySelector ( '[data-testid="chart-container"]' ) ,
134- document . querySelector ( '[data-testid="chart-container-v9"]' )
135- ] ;
136-
137- containers . forEach ( container => {
138- if ( container ) {
139- const chartDivs = container . querySelectorAll ( 'div[style*="height"], div[class*="chart"]' ) ;
140- chartDivs . forEach ( ( div : any ) => {
141- if ( div && div . style ) {
142- const targetHeight = height - 120 ;
143- div . style . height = `${ targetHeight } px` ;
144- div . style . maxHeight = `${ targetHeight } px` ;
145- }
146- } ) ;
132+ // Find all chart containers by class names
133+ const chartRoots = document . querySelectorAll ( '[class*="chartWrapper"]' ) ;
134+ chartRoots . forEach ( ( root ) => {
135+ if ( root ) {
136+ const parent = ( root as HTMLElement ) . parentElement ?. parentElement ;
137+ if ( parent ) {
138+ parent . style . height = `${ height } px` ;
139+ parent . style . minHeight = `${ height } px` ;
140+ parent . style . maxHeight = `${ height } px` ;
141+ }
147142 }
148143 } ) ;
149144 } ;
@@ -153,7 +148,7 @@ const DeclarativeChartBasicExample: React.FC<IDeclarativeChartProps> = ({ width,
153148 const timeoutId = setTimeout ( applyHeightToCharts , 500 ) ;
154149
155150 return ( ) => clearTimeout ( timeoutId ) ;
156- } , [ height , chartRenderKey ] ) ;
151+ } , [ height , chartRenderKey , isRTL ] ) ;
157152
158153 const _onChange = ( event : SelectionEvents | null , data : OptionOnSelectData ) : void => {
159154 const selectedChoice = data . optionText ! ;
@@ -163,6 +158,8 @@ const DeclarativeChartBasicExample: React.FC<IDeclarativeChartProps> = ({ width,
163158 setSelectedChoice ( selectedChoice ) ;
164159 setSelectedSchema ( selectedSchema ) ;
165160 setSelectedLegendsState ( JSON . stringify ( selectedLegends ) ) ;
161+ // Force re-render to ensure height is applied to new chart
162+ setChartRenderKey ( prev => prev + 1 ) ;
166163 } ;
167164
168165 const _onSelectedLegendsEdited = (
@@ -229,6 +226,8 @@ const DeclarativeChartBasicExample: React.FC<IDeclarativeChartProps> = ({ width,
229226 const fileNumberMatch = firstFilteredSchema . fileName . match ( / \d + / ) ;
230227 const num_id = fileNumberMatch ? fileNumberMatch [ 0 ] : '0' ;
231228 saveSelection ( SCHEMA_KEY , num_id . toString ( ) . padStart ( 3 , '0' ) ) ;
229+ // Force re-render to ensure height is applied to new chart
230+ setChartRenderKey ( prev => prev + 1 ) ;
232231 } else {
233232 setSelectedChoice ( '' ) ;
234233 setSelectedSchema ( { } ) ;
@@ -259,6 +258,8 @@ const DeclarativeChartBasicExample: React.FC<IDeclarativeChartProps> = ({ width,
259258 const fileNumberMatch = firstFilteredSchema . fileName . match ( / \d + / ) ;
260259 const num_id = fileNumberMatch ? fileNumberMatch [ 0 ] : '0' ;
261260 saveSelection ( SCHEMA_KEY , num_id . toString ( ) . padStart ( 3 , '0' ) ) ;
261+ // Force re-render to ensure height is applied to new chart
262+ setChartRenderKey ( prev => prev + 1 ) ;
262263 } else {
263264 setSelectedChoice ( '' ) ;
264265 setSelectedSchema ( { } ) ;
0 commit comments