piechart
piechart with custom data
by Tapan Acharjee
HTML
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<meta charset="utf-8" />
<title> Highcharts directive demo </title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
</head>
<body ng-controller="myController">
<hc-chart options="chartOptions">Placeholder for generic chart</hc-chart>
<hc-pie-chart title="Browser usage" data="pieData">Placeholder for pie chart</hc-pie-chart>
<script>
angular.module('myModule', [])
// Directive for generic chart, pass in chart options
.directive('hcChart', function () {
return {
restrict: 'E',
template: '<div></div>',
scope: {
options: '='
},
link: function (scope, element) {
Highcharts.chart(element[0], scope.options);
}
};
})
// Directive for pie charts, pass in title and data only
.directive('hcPieChart', function () {
return {
restrict: 'E',
template: '<div></div>',
scope: {
title: '@',
data: '='
},
link: function (scope, element) {
Highcharts.chart(element[0], {
chart: {
type: 'pie'
},
title: {
text: scope.title
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
...