jquery - Custom text in tooltip and legend: ChartJs -


im using doughnut chartjs. tooltip text long gets cut. wanted add ellipsis(...) @ end of tooltip text. ellipsis gets added in legend also. how add different text in legend , tooltip?

controller.js

doughnutdata.push({ 'value': value.count, color: $scope.doughnutcolors[key], highlight: $scope.doughnutcolors[key], label: value.website }); 

directive.js

$scope.mydoughnut = new chart(ctx).doughnut(value, {                     showscale: true, scaleshowlabels: true, animation: false,                     tooltiptemplate: "<%if (label){%><%=label%>:<%=value%>%<%}%>",                     legendtemplate: "<ul class=\"doughnutalt-legend\"><% (var i=0; i<segments.length; i++){%><li><span style=\"border-color:<%=segments[i].fillcolor%>\"></span><label><%if(segments[i].label){%><%=segments[i].label%><%}%></label></li><%}%></ul>", }); 

fixed it

{ ... tooltiptemplate: function (label) {                         return customtooltip(label);                     }  });  function customtooltip (label) {                     if (label.label.length > 10) {                         label.label = label.label.substring(0,10)+'...';                     }                     return label.label+': '+label.value+'%'; } 

don't know if right code. did wanted


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -