Our application allows users to select between 1 and 8 elements to report on (creating between 1 and 8 bars or lines in each report), and allows them to enter a name for each element between 1 and 255 characters long. This caused headaches for us in the charts as legends would overlap severely, take up too much space, or disappear entirely because they were too large.<br />
<br />
We added this snippet as a Data Binding expression in the chart:
var str = row["GroupName"];
if(str.length > 25)
{
str.substring(0,10) + ' ... ' + str.substring((str.length - 10), str.length);
}
else
{
str;
}
<br />
When the GroupName item is longer than 25 characters, this code removes the middle of it to produce a 25 character long string. If the GroupName was 'First group name of many many characters' it becomes 'First grou ... characters'.<br />
We found this more useful than just trimming the end off as it gives a hint of the start and end of the string (helps when users have named groups something similar).<br />
<br />
This isn't a super complicated snippet, but it really helped us. Hope someone else can benefit from it!