Skip to content

Instantly share code, notes, and snippets.

View Sherbin's full-sized avatar
💭
I can see the whole room...and there's nobody in it

Щербин Сергей Sherbin

💭
I can see the whole room...and there's nobody in it
View GitHub Profile
<p>To send command into some widget we use PostMessage (https://developer.mozilla.org/ru/docs/Web/API/Window/postMessage)<br>
Way to find required <iframe> is option "id" passed for initialization</p>
<p>Javascript and further HTML is Exapmle</p>
<p>NOTE: We use this tricky way because we need to handle all widgets the same. Both initialized with tv.js (https://www.tradingview.com/widget/advanced-chart/) and initialized self-replaced script (https://www.tradingview.com/widget/technical-analysis/)</p>
<!-- Example start -->
<!-- Advanced chart widget initialization -->
<div id="advanced-chart-widget-container"></div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
@Sherbin
Sherbin / formatValue.js
Created October 23, 2017 07:07
tv - financial tabs formatter
function formatValue(value, field) {
var number = parseFloat(value);
// floats greater than maxNumberic will be formatted like an integer
var maxNumeric = Math.pow(10, 6);
if (isNaN(number)) {
return value;
}
if (fieldTypes[field] === 'percent') {