google-visualization - 谷歌图表中的自定义排序功能

标签 google-visualization

我需要一个对其中一列进行自定义排序的谷歌图表表。
我用 sort: 'event, 我猜这应该发出一些可以捕获的事件,但没有找到任何关于它的信息。

最佳答案

使用事件处理程序捕获“排序”事件:

// table is your Table visualization
google.visualization.events.addListener(table, 'sort', function (e) {
    // e.column is the column to sort
    // e.ascending is a boolean, true for ascending sort, false for descending sort

    // sort your data

    // if you want the ascending/descending elements to work correctly, you need to specify the Table's sortColumn and sortAscending options when you redraw the Table, eg:
    options.sortColumn = e.column;
    options.sortAscending = e.ascending;
    table.draw(sortedData, options);
});

关于google-visualization - 谷歌图表中的自定义排序功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25848409/

相关文章:

php - 根据输入从 php 接收图表

JavaScript Date 对象的月份索引从 0 开始

javascript - 谷歌图表(饼图)中图例的新行

javascript - 如何在放大谷歌图表后停止默认字体大小

javascript - 在for循环中创建多个图表

charts - Google图表更改了Haxis字体大小

javascript - Google Charts ColumnChart 日期格式不显示分钟和小时

javascript - 如何将字符串更改为 Google 图表数据

javascript - 通过链接谷歌可视化表包装每一行

javascript - 谷歌图表列着色?