1

我们计划在我们的项目中使用谷歌图表,我们使用 Angular JS 作为前端。(Angular 和 Google 图表的新功能)

Google 图表是否提供任何现成的 UI来配置每种类型的图表?

如果用户选择图表类型,它应该向用户显示配置,一旦用户选择,它将应用于该图表。

前任:

  1. 如果选择饼图,将显示“pieHole”字段。

  2. 如果选择条形图,将显示“isStacked”字段。

提前致谢 :)

4

1 回答 1

1

查看ChartEditor课程

以下工作片段打开一个带有填充饼图的图表编辑器对话框

当图表编辑器打开时,查看各种图表选项 的自定义选项卡

点击“确定”将图表保存到<div>页面上

google.charts.load('current', {
  callback: function () {
    var chartEditor = null;

    // Create the chart to edit
    var chartWrapper = new google.visualization.ChartWrapper({
      chartType: 'PieChart',
      dataTable: new google.visualization.DataTable({
        "cols": [
          {"label": "Country", "type": "string"},
          {"label": "# of Devices", "type": "number"}
        ],
        "rows": [
          {"c": [{"v": "Canada"}, {"v": 33}]},
          {"c": [{"v": "Mexico"}, {"v": 33}]},
          {"c": [{"v": "USA"}, {"v": 34}]}
        ]
      })
    });
    chartEditor = new google.visualization.ChartEditor();
    google.visualization.events.addListener(chartEditor, 'ok', redrawChart);
    chartEditor.openDialog(chartWrapper, {});

    // On "OK" save the chart to a <div> on the page.
    function redrawChart(){
      chartEditor.getChartWrapper().draw(document.getElementById('chart_div'));
    }
  },
  packages:['charteditor', 'controls']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

于 2016-12-01T19:51:39.377 回答