首页 > 解决方案 > pieSliceText 在谷歌图表中的位置

问题描述

我想在谷歌饼图中显示百分比文本,在圆边缘的饼图之外。我怎么做 ?

  function drawChart() {
    // Create the data table.
    var data = new google.visualization.DataTable();
    data.addColumn("string", "Topping");
    data.addColumn("number", "Slices");
    data.addRows([
      ["Mushrooms", 3],
      ["Onions", 1],
      ["Olives", 1],
      ["Zucchini", 1],
      ["Pepperoni", 2]
    ]);

    // Set chart options
    var options = {
      title: "How Much Pizza I Ate Last Night",
      width: 400,
      height: 300,
      pieHole: 0.4,
      pieSliceTextStyle: { color: "black", fontSize: 10 }            
    };

    // Instantiate and draw our chart, passing in some options.
    var chart = new google.visualization.PieChart(
      document.getElementById("chart_div")
    );
    chart.draw(data, options);
  }

如果做不到。有没有更好的工具来创建饼图?

标签: google-visualization

解决方案


推荐阅读