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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -