javascript - Angular-Charts - Pie Chart,show labels inside each slice of data -


i learning stage of angular-chart-js. trying use angular-chart.js plot pie chart. unable find way showing labels (not tooltips) on pie chart, describe each slice of data.

here how did it:

angular.module('app').controller('controller', ['$scope', '$http', '$location', '$window', '$routeparams',      function($scope, $http, $location, $window) {          var diskdatajson = {              "data": [80, 12],              "labels": [used space, free space],              "colours": ['#9ab6f0', '#c2d3f6']          };                $scope.piediskdata = json;      }  ]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <table border="0" width="100%">    <tr>      <td style="border-left: 1px solid #0099cc" width="25%">        <center><span><label ng-bind-html="'load.static.dashboard.system.dusage' | translate"/></span>        </center>        <canvas id="pie33" class="chart chart-pie chart-xs ng-isolate-scope" height="120" width="240" data="piediskdata.data" labels="piediskdata.labels" colours="piediskdata.colours" legend="true"></canvas>      </td>    </tr>  </table>

adapted https://stackoverflow.com/a/25913101/360067 angular-chart

add following options scope

$scope.options = {     tooltipevents: [],     showtooltips: true,     tooltipcaretsize: 0,     onanimationcomplete: function () {         this.showtooltip(this.segments, true);     }, }; 

and use in directive

<canvas id="pie33" options="options"... 

fiddle (with relevant sections code) - http://jsfiddle.net/zuhp8k5f/154/


enter image description here


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -