@domoinc/multiline-chart
Version:
MultiLineChart - Domo Widget
16 lines (12 loc) • 783 B
JavaScript
//**********************************************************************************
// This function will truncate a given text string to the given number of
// characters.
// It will also give you the option of truncating words on a word boundary.
//**********************************************************************************
function domoUtilTruncateStringToNumCharacters(string, numCharacters, useWordBoundary) {
console.warn("The domoUtilTruncateStringToNumCharacters method has been deprecated. Use d3.domoStrings.trunc instead.")
var toLong = string.length > numCharacters;
var s_ = toLong ? string.substr(0, numCharacters - 1) : string;
s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(' ')) : s_;
return toLong ? s_ + '...' : s_;
}