Trying to add TradingView widget into my website.
This widget must load when user select
an option from a dropdown.
Issue: The widget loads, but it replaces everything in the body and thereby the dropdown disappear.
Example:
HTML Code:
<select name="fx" class="fx">
<option value="EURUSD">EURUSD</option>
<option value="EURJPY">EURJPY</option>
</select>
JS:
function changeFX(fx){
var fxWidget = new TradingView.widget({
"width": 500,
"height": 400,
"symbol": "FX:"+fx,
"interval": "1",
"timezone": "Etc/UTC",
"theme": "White",
"style": "2",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"hide_top_toolbar": true,
"save_image": false,
"hideideas": true
});
return themeWidget;
}
$(document).on('change','.fx',function(){
var widget = changeFX(this.value);
// do something with widget.
});
http://jsfiddle.net/livewirerules/3e9jaLku/5 (select dropdown option, and see widget loads but dropdown disappears)
Any advice how to make the dropdown doesn't disappear and still TradingView widget load?
Customize Widget Once you've selected a widget, you will need to customize it (Click 'Get Widget' on TradingView). Configure the on-screen widget options within TradingView. Once you're done click 'Apply'.
Easiest and best way to quickly add financial charts to your site, blog or forum is to embed our free real-time charting and quotes widgets.
Advanced Real-Time Chart Widget. Here's a free and powerful chart for you to easily embed onto any website. Make it yours with a ton of different customization options.
To easily change the style of your chart on TradingView, navigate to the top left-hand corner of a chart and left click the “chart styles” button. This will allow you to change your chart to the various types supported by TradingView.
It's certainly too late, but you can use the argument "container_id" to choose where to place the graph.
source : https://github.com/mmmy/css3demos/wiki/Widget-Constructor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With