重新排序Keen.io中的表列

时间:2018-01-18 15:26:38

标签: tablecolumn keen-io

我正在尝试弄清楚如何对从提取查询构建的表上的列重新排序。更改“property_names”字段中的顺序不会影响显示的列顺序。我希望在“文本”列之前显示“subjectivity_range”列。

我的代码是:

Keen.ready(function() {
var textq = new Keen.Query("extraction", {
     event_collection: source,
     timeframe: 'this_1_days',
     refresh_rate: "28000",
     property_names: ["subjectivity_range","text"],
     order_by: {'subjectivity_range':'result','direction':'DESC'},
     timezone:"US/Eastern"
    });
     .type('table')
     .title('Subjectivity examples')
     .prepare();

  client.run(textq, function(err, res) {
      textchart
      .data(res)
      .parseRequest(this)
      .render();
    });
});

1 个答案:

答案 0 :(得分:0)

https://github.com/keen/keen-dataviz.js#extraction-table-columns-order

/*
 dummy event model
 {
   user: {
     email: 'john@doe.com'
   },
   favourite_fruit: 'Avocado'
 }
*/

const chart = new KeenDataviz({
  container: '#some_container', // required
  table: {
    columns: ['favourite_fruit', 'user.email', 'keen.created_at'] // custom order of the columns
  }
});

您可以使用AZ排序,例如 - 降序:

   chartElement
     .data(responseFromApi)
     .sortGroups('desc')
     .render();