As you probably know, the charting library is not accessible publicly. You need to request access from them. So, I can't really give a complete repo as an example. I did however open a PR at https://github.com/tradingview/charting-library-examples/pull/197, but I'm not sure if it's going to be accepted.
Anyway, the given example is using asset pipeline and the modern Ruby on Rails application is using webpacker. So after trying out a few times, I figured a working way to load the sample chart.
It's not straight forward for me, so maybe this will help someone else in the future. However, I'm not sure if it's the best way to load it, however, it works 😁
I'm going to assume you're using the Ruby on Rails v220.127.116.11. Once you've cloned the library into
charting_library directory, you can do these steps:
Don't worry about serving outdated files just because you put it in the public directory as the charting library will use a new hash on the files every time there's a new update.
Once we got the files in the correct places, we can use this code to load the sample:
The code is actually coming from the sample with slight modifications.
Create a view and put this HTML in:
<div class="page-tv-chart-container" id="tv_chart_container"> </div>
TradingView will use that ID to load the chart.
Just start your server and that's it. You should have a working TradingView chart by now 👍