Setting widget container height individually
-
Dear forum members,
In individual blogposts su I insert Tradingview stock chart widgets.
The widget code is obtainable frI’m https://www.tradingview.com/widget/advanced-chart/
I select the stock and configuration options and then check the ‘Autosize’ box so that the widget does not spread out of the screen width but in order to avoid it being crushed vertically the container height needs to be defined.
I found the solution to be an additional CSS added and for the two pages linked here above the code is:
#tradingview_813bd div { height: 600px !important; } #tradingview_49ae5 div { height: 600px !important; }
but as you recognize, I need to add an additional code for every single widget inserted into a blogpost because each widget has a specific id, such as ‘813bd’ and ’49ae5′ here above.
I am wondering if there is not a possibility to insert a line of code to set the heigth of the widget directly in the widget code.
The widget code typically is:
<!-- TradingView Widget BEGIN --> <div class="tradingview-widget-container"> <div id="tradingview_e61f1"></div> <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div> <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script> <script type="text/javascript"> new TradingView.widget( { "autosize": true, "symbol": "NASDAQ:AAPL", "interval": "D", "timezone": "Etc/UTC", "theme": "Light", "style": "1", "locale": "en", "toolbar_bg": "#f1f3f6", "enable_publishing": false, "allow_symbol_change": true, "container_id": "tradingview_e61f1" } ); </script> </div> <!-- TradingView Widget END -->
Does this idea make sense?
Thanks a lot for help.
The page I need help with: [log in to see the link]
- The topic ‘Setting widget container height individually’ is closed to new replies.