dataTable should probably not use .top(), .bottom()
See original GitHub issueHi, I’m trying to implement data table(car model name and speed) and select menu (Day- monday and so). Link to the demo site my json data here is my code for data table
var car = dc.dataTable('#car')
.dimension(carGrpdDim)
.group(function (d){ return 'Modal | Speed'})
.columns([function (d) { return d.key }, function (d) { return d.value.total }])
.sortBy(function (d) { return d.value.total })
.order(d3.descending)
.size(5)
select menu code
var day = dc.selectMenu('#day')
.dimension(dayDim)
.group(dayGrp)
.controlsUseVisibility(true)
.promptText('Day');
day.title(function (d) {
return d.key;
});
i want to show only top 5 cars for the day. So i added size(5)
but I’m getting cars with speed 0. Though I have cars with speed greater than 0.
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
DataTable paging at top and bottom of table
I managed to add the paging control at the top and bottom of the table by specifying to dom option.
Read more >top and bottom controls on a single table — DataTables forums
Hi guys, Yes, this is something which crops up relatively frequently. The reason it doesn't currently work completely is that DataTables ...
Read more >DOM positioning - DataTables example
In the example below, the table information is moved to the top of the table, and all the interaction elements to the bottom,...
Read more >How to fix a row with sorting enabled — DataTables forums
Hi Im looking for a way to allow sorting but keep the first data row FIXED at top. See green row in image....
Read more >Datatables table loads twice, first time without table data
Or it could be that one of those is when you redeclare oTable as datatable. Not 100% sure, but certainly there is redundancy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for including a reproducible example! The issue here is that the data table uses dimension.top(N) to determine which rows to show when
dataTable.size()
is enabled.Since you are using a group for your dimension, that resolves to group.top(N), which
The “group order” is determined by group.order(f), and by default that attempts to use the reduced values directly for ordering. This won’t work in your case because the reduced values are objects. I guess this somehow results in a no-op, so you get the first five in alphabetical ordering based on the key.
You can fix your example by specifying
group.order()
:Demo fiddle: https://jsfiddle.net/gordonwoodhull/cbyktand/10/
The use of
.top()
is documented quite a few places in the dataTable documentation, however it’s pretty confusing. I don’t think it would be a huge performance hit to just taketop(Infinity)
, then sort and cap, as we are already doing in the capped charts (pie, row) per #934.I’ll retitle this issue accordingly. It’s a little tricky to do in a backward compatible way, but we mostly succeeded for the capped charts.
Thanks @gordonwoodhull . It solved the issue.