1

I am new using dc.js library. I was trying to create a chart filter that fills a data table as feedback. So on, I start to use the already implemented component dc.dataTable.

I already know that is possible to increase the number of "displayed data elements" in the dataTable by using .size(10). However, in situations where my filter returns a big amount of data elements, it gets tricky for me display them all at once.

So, this leads to my question:

Is it possible to paginate a dc.dataTable provided by dc.js?

Roger A. Leite
  • 394
  • 2
  • 18
  • I think you'd have to create a fake dimension, then have the fake dimension's 'top' method return records from the real dimension's 'top' method depending on where you currently are in the pagination. However, I think pagination is probably a mistake as it doesn't fit with dc.js's interaction model. i.e. What happens to your pagination position when you filter on another chart? – Ethan Jewett Sep 25 '15 at 13:31
  • Sorry, not so sure if I understood well. But if I did, I would say that it is reloaded with the dimension filter. It already happens with the dc.dataTable content. For instance, if I am exploring third page, and at this point I decide to generate a new filter, the dataTable gets reload to the first page(it is a new rule, after all). – Roger A. Leite Sep 25 '15 at 13:54
  • The whole idea of dc.js and Crossfilter is that you can display multiple dimensions in coordinated charts. Filtering on a chart is applied immediately to all dimensions. You can use dc.js for single, disconnected charts as well though, and if that's what you want to do, then the question makes more sense! – Ethan Jewett Sep 25 '15 at 15:15
  • First of all, thank you for your answers so far Ethan Jewett. – Roger A. Leite Sep 25 '15 at 15:46
  • https://imgur.com/jMl6Btw this image shows what I intend to do. (1) apply a filter, (2) check the items list in the table... As you can see, in this example 4.284 items were returned after the filter. What I am looking for, is a way to iterate trough this table. A nice solution would be the "next>>" button proposed in the image. Is this possible? – Roger A. Leite Sep 25 '15 at 15:52
  • Yes, it's possible using a fake dimension. But let's say someone selects Friday as shown, clicks next a few times so they are on the 4th page of results. Then they click Thursday. What happens? – Ethan Jewett Sep 25 '15 at 20:42
  • 1
    @Ethan, I think the proper behavior would be either to show the same page of the other results (which might be empty), or to return to page 1. A simple pagination system has been added for the data grid and it should be trivial to apply the same changes to the data table, since the former is based on the latter. [beginSlice/endSlice](https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#dc.dataGrid+beginSlice) – Gordon Sep 26 '15 at 03:18
  • @Gordon I think that's going to be really confusing behavior for users in either case, but would probably make sense to provide the same API. – Ethan Jewett Sep 26 '15 at 15:03
  • [Here is the original PR for the data grid](https://github.com/dc-js/dc.js/pull/946) if anyone wants to port those changes over before I get to it. – Gordon Sep 26 '15 at 21:12
  • @Ethan, I got your point. Maybe there is no correct answer for that. Personally, I would prefer a full refresh of the table, backing the pagination to the page 1. I would argue for that, thinking that usually the table analysis is the last step in a filter search. Thus, it decreases the re-filter chances. In addition, restart the table from the first page after filtering would also alert the user about the changes. – Roger A. Leite Sep 27 '15 at 21:50
  • @Gordon, just .beginSlice .endSlice didn`t work for me =/ (".beginSlice is not a function"). By now, the most similar solution that I found was [this](http://stackoverflow.com/questions/21596616/dc-js-data-table-using-jquery-data-table-plugin/25901167#25901167). Still, I would prefer a solution that don`t need an extra library. Anyway, I will keep my search. If I find something, I post it here. Thank you and @Ethon for being awesome and support the dc.js community. =). – Roger A. Leite Sep 27 '15 at 22:30
  • Yeah, maybe I wasn't clear, the feature is available on the data *grid* not the data *table*. I think it could be easy to port the changes from that grid PR to the table but I haven't tried. It's the community that makes dc.js awesome! – Gordon Sep 27 '15 at 23:02

0 Answers0