删除 Google 可视化饼图中的图例

Removing Legend in Google Visualization Pie Chart

我想隐藏饼图中的标签。我认为正确的词是标签?但我可能是错的。基本上我有一个显示一些数据的饼图,在饼图之外它有一个带有颜色立方体的标签,旁边有一个名称显示每种颜色代表什么,我想摆脱它,因为在悬停时我显示相同的数据,它占用了我想使用的一些宝贵的空间。这是我的 Javascript 代码:

 google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);

    function drawChart() {
        var options = {
            title: '',
            is3D: true
        };
        $.ajax({
            type: "POST",
            url: "myPage.aspx/GetChartData",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                //console.log(JSON.stringify(r))
                var data = google.visualization.arrayToDataTable(r.d);
                var chart = new google.visualization.PieChart($("#chart")[0]);
                var formatter = new google.visualization.NumberFormat(
  { negativeColor: 'red', negativeParens: true, pattern: '$###,###.##' });
                formatter.format(data, 1);
                chart.draw(data, options);
            },
            failure: function (r) {
                alert(r.d);
            },
            error: function (r) {
                alert(r.d);
            }
        });
    }

Google图表可视化,绝杀图例:

legend: {position: 'none'} 

-- 这将杀死 Google 图表中的图例。

另外,JS 做的:

http://jsfiddle.net/api/post/library/pure/

legend: 'none'

所以,最终这应该为你做:

google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);

    function drawChart() {
        var options = {
            title: '',
            is3D: true,
            legend: none,
        };
        $.ajax({
            type: "POST",
            url: "myPage.aspx/GetChartData",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                //console.log(JSON.stringify(r))
                var data = google.visualization.arrayToDataTable(r.d);
                var chart = new google.visualization.PieChart($("#chart")[0]);
                var formatter = new google.visualization.NumberFormat(
  { negativeColor: 'red', negativeParens: true, pattern: '$###,###.##' });
                formatter.format(data, 1);
                chart.draw(data, options);
            },
            failure: function (r) {
                alert(r.d);
            },
            error: function (r) {
                alert(r.d);
            }
        });
    }