Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using aggregated data in data table #927

Closed
yetanotherion opened this issue Apr 29, 2015 · 9 comments
Closed

using aggregated data in data table #927

yetanotherion opened this issue Apr 29, 2015 · 9 comments
Labels
Milestone

Comments

@yetanotherion
Copy link
Contributor

Hello to all,

Let's take an example of

  • data = list of cars.
  • car an object with attributes ("brand", "price_sold", "date_sold", "country_sold").

I'd like to display a "ranking" table that sorts the brands, from the more to the less sold.
Thanks to the group and sortBy functions, I'm currently able to make a table that displays something like

  • most_sold_brand
    • ...
    • most_sold_brand, price_sold_i, date_sold_i, country_sold_i
    • ...
  • second_most_sold_brand
    • ...
    • second_most_sold_brand, price_sold_j, date_sold_j, country_sold_j
    • ...
  • ...

This table is however hard to read for ranking purposes, as all the *_i, *_j should be filtered manually
to have the ranking information.

What would be nice, would be to have:

  • a table, like
    • most_sold_brand, number_of_most_sold_brand_cars_sold
    • second_most_sold_brand, number_of_second_most_sold_brand_cars_sold
    • ...
  • that is still refreshed by the different dimension selections performed in other charts (which I find by the way, to be an awesome feature :))

I currently don't manage to implement that, as the group in table does not
support groups created by means of the dimension.group().reduce(add, del, init) pattern.

Do you have any suggestions on how to do so ?

@AlanKavanagh
Copy link
Contributor

If I am understanding you correctly then you just want to remove the headings? Why not add a postRender event which gets all sub elements with class .dc-table-label and removes them? Also this is more suited for StackOverflow than the issues since it is a question not an issue with the library. Hope that helps.

@gordonwoodhull
Copy link
Contributor

@yetanotherion, my understanding of the request is to use a group instead of a dimension for the data for the data table. Because you want reduced values in the cells instead of raw rows.

I believe this is already supported, by accident. The coupling between dc and crossfilter is very light, so the data table is just calling .all() and .top(N) on the dimension and this also works with a group.

See this PR which depends on this: #697

In fact, the data table does not use "groups" like any other dc chart - instead it takes a group function which generates the values to nest by.

I delayed in answering because I wanted to create an example and update the documentation, but I don't have time at the moment.

Could you please try this out and report if it works? (And if you are very kind, post a simple example.)

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone Apr 29, 2015
@gordonwoodhull
Copy link
Contributor

Not helpful to OP but just to create the link, here's an equivalent issue on crossfilter, really a documentation issue here: square/crossfilter#150

@gordonwoodhull
Copy link
Contributor

More notes for myself or other maintainers.

The odd group function is documented in a comment in the stock example and nowhere else.

https://github.com/dc-js/dc.js/blob/develop/web/stock.js#L453-L458

It could be documented in the way that the special .group() is documented for the data count widget (but note the vague link generated, and the missing dots on the other data count member documentation).

https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#groupgroupall---mandatory

@yetanotherion
Copy link
Contributor Author

Thanks ! It works indeed, as soon as:

  • the .group() is defined, and returns the same value for all elements
  • the .order() is defined & defined to something else than the default
    value which seems to be either d3.ascending or descending.
    (a method that is undefined for .reduce()-d dimension groups is called
    else).

Where would you like that I write an example that illustrates this ?

2015-04-30 0:15 GMT+02:00 Gordon Woodhull [email protected]:

More notes for myself or other maintainers.

The odd group function is documented in a comment in the stock example and
nowhere else.

https://github.com/dc-js/dc.js/blob/develop/web/stock.js#L453-L458

It could be documented in the way that the special .group() is documented
for the data count widget (but note the vague link generated, and the
missing dots on the other data count member documentation).

https://github.com/dc-js/dc.js/blob/master/web/docs/api-latest.md#groupgroupall---mandatory


Reply to this email directly or view it on GitHub
#927 (comment).

Ion

@gordonwoodhull
Copy link
Contributor

Great! If you can, please create a PR to add the example to web/examples which gets deployed here.

@yetanotherion
Copy link
Contributor Author

#929

I'm not sure of the "table-on-aggregated-data", name and my editor added a newline to the index.html (did not manage to remove it for now).

@gordonwoodhull
Copy link
Contributor

Thanks! That's fine, the index is generated anyway.

@gordonwoodhull
Copy link
Contributor

Documented in #929

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants