Skip to content

Instantly share code, notes, and snippets.

@Sherbin
Created October 23, 2017 07:07
Show Gist options
  • Select an option

  • Save Sherbin/0e9326901f6f5462ad36b2d11c042067 to your computer and use it in GitHub Desktop.

Select an option

Save Sherbin/0e9326901f6f5462ad36b2d11c042067 to your computer and use it in GitHub Desktop.
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') {
return percentageFormatter.format(number);
} else if (TradingView.isInteger(number) || (isNumber(number) && Math.abs(number) > maxNumeric)) {
return volumeFormatter.format(number);
} else if (isNumber(number)) {
return numericFormatter.format(number);
}
return number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment