如何在Google饼图切片上一起显示标签,价值和百分比?

时间:2018-07-13 10:28:18

标签: pie-chart google-pie-chart

我要求在Google饼图切片上同时显示所有三个标签,值和百分比。我可以显示标签,也可以显示值和百分比,但不能一起显示。我正在使用以下代码:-

   google.charts.load('current', { 'packages': ['corechart'] });
   google.charts.setOnLoadCallback(drawChart);

function drawChart() {
    $.ajax({
        type: 'GET',
        url: '/' + '@Area' + '/Report/Page4',
        dataType: "json",
        success: function (result) {
            var Combined = new Array();
            Combined[0] = ['Name', 'Count'];
            for (var i = 0; i < result.length; i++) {
                Combined[i + 1] = [result[i].Name,   parseInt(result[i].count)];
            }
            var data = google.visualization.arrayToDataTable(Combined, false);

            var options = {

               // pieSliceText: 'value-and-percentage' // Working
               // pieSliceText: 'label' // Working

               // I want to do something like this as follows

               //  pieSliceText: 'label-value-and-percentage' // Not Working

            };
            var chart = new google.visualization.PieChart(document.getElementById('page4'));
            chart.draw(data, options);

0 个答案:

没有答案