Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TradingView widget replacing entire HTML body

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?

like image 615
Zeigeist Avatar asked Jan 14 '17 11:01

Zeigeist


People also ask

How do I customize my Tradeview widget?

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'.

Can I use TradingView charts on my website?

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.

Is Tradeview widget free?

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.

How do I change the view on Tradeview?

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.


1 Answers

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

like image 106
gg0512 Avatar answered Oct 01 '22 01:10

gg0512