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
Post a Comment