1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
angular.module('xxModule').factory('xxxService', function(){ return {
_createPie: function(Title, documentID, arrayData) { var chart = { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }; var title = Title;
var tooltip = { shared: true, useHTML: true, style: { color: 'orange', fontSize: '8px', fontWeight: 'normal', fontFamily: 'Microsoft YaHei' }, pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' }; var plotOptions = { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, useHTML: true, maxStaggerLines: 1, style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black', fontFamily: 'Microsoft YaHei', fontSize: '8px' }, formatter: function() { var text; if (this.point.name.length > 3) { text = '<a title="' + this.point.name + '">' + this.point.name.substring(0, 2) + '</a>'; } else { text = this.point.name; } return text + ": " + this.percentage.toFixed(2) + "%"; }
}, showInLegend: true } }; var legend = { layout: 'vertical', align: 'right', verticalAlign: 'top', borderWidth: 0, itemStyle: { 'fontSize': '10px', 'font-family': 'Microsoft YaHei' }, useHTML: true, labelFormatter: function() { var legendMsg; legendMsg = '<a title="' + this.name + '">'; if (this.name.length > 5) { legendMsg += (this.name).substring(0, 3); legendMsg += '...'; legendMsg += (this.name).substring(this.name.length - 2, this.name.length); } else { legendMsg += this.name; } legendMsg += '</a>'; return legendMsg; } }; var series = [{ type: 'pie', name: '百分比: ', data: arrayData }]; var credits = { enabled: false };
var json = {}; json.chart = chart; json.title = title; json.tooltip = tooltip; json.series = series; json.plotOptions = plotOptions; json.legend = legend; json.credits = credits; $(documentID).highcharts(json); }
}; });
|