【问题标题】:Google visualisation ColumnChart data谷歌可视化柱形图数据
【发布时间】:2014-03-13 03:51:52
【问题描述】:

在这里,我根据这些数据创建了一个仪表板http://jsbin.com/OJAnaji/27/edit(googl 可视化):

data = google.visualization.arrayToDataTable([
        ['Name', 'Gender', 'Age', 'Donuts eaten'],
        ['Michael' , 'Male', 12, 5],
        ['Elisa', 'Female', 20, 7],
        ['Robert', 'Male', 7, 3],
        ['John', 'Male', 54, 2],
        ['Jessica', 'Female', 22, 6],
        ['Aaron', 'Male', 3, 1],
        ['Margareth', 'Female', 42, 8],
        ['Miranda', 'Female', 33, 6]
    ]);

除了 ColumnChart 之外一切正常,因为我得到了错误: 给定轴上的所有系列必须是相同的数据类型×

柱形图代码:

var wrapper = new google.visualization.ChartWrapper({
    chartType: 'ColumnChart',
    containerId: 'chart3'
  });

和绘图功能:

// Create a dashboard
    new google.visualization.Dashboard(document.getElementById('dashboard')).
    // Establish bindings, declaring the both the slider and the category
    // picker will drive both charts.
    bind([slider, categoryPicker, stringFilter], [pie, table, wrapper]).
    // Draw the entire dashboard.
    draw(data, {'allowHtml':true, 'cssClassNames': 'cssClassNames'});      
}
google.load('visualization', '1', {packages:['controls'], callback: drawVisualization});

和 HTML:

          <div class="col-md-4" style="float: left;" id="chart3"></div>

我有什么方法可以显示(过滤数据)等。Y 轴上的“姓名”列和 X 轴上的“年龄”或 Y 轴上的“姓名”列和 X 轴上的“吃的甜甜圈”???

更新:我正在尝试这个:

“视图”:{“列”:[0,3]}

但是什么都没发生

【问题讨论】:

    标签: javascript html google-visualization googlevis


    【解决方案1】:

    您是否在包装器中指定了视图?

    var wrapper = new google.visualization.ChartWrapper({
        chartType: 'ColumnChart',
        containerId: 'chart3',
        view: {
            columns: [0,3]
        }
    });
    

    顺便说一句,将第二个参数传递给 Dashboad#draw 调用不会做任何事情 - 它不接受任何选项:

    new google.visualization.Dashboard(document.getElementById('dashboard')).
    // Establish bindings, declaring the both the slider and the category
    // picker will drive both charts.
    bind([slider, categoryPicker, stringFilter], [pie, table, wrapper]).
    // Draw the entire dashboard.
    draw(data);
    

    这些应该作为 options 参数在适当的 ChartWrapper 中传递(可能是 Table 的包装器,给定指定的选项)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      • 1970-01-01
      • 2015-12-22
      • 1970-01-01
      • 1970-01-01
      • 2013-09-24
      • 1970-01-01
      相关资源
      最近更新 更多