Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improvement on dc-data-count #527

Closed
tttp opened this Issue · 4 comments

2 participants

@tttp

The default example for dc-data-count is

<div class="dc-data-count"><span class="filter-count"></span> selected out of <span class="total-count"></span> records | <a href="javascript:dc.filterAll(); dc.renderAll();">Reset filters</a></div>

When you have a filter, it works great, however, when you don't, it displays:
42 selected out of 42 records | Reset filters

1) it's wrong to offer to Reset filters when they aren't any
2) x selected out of x is correct, but feels "nerdy"
3) more importantly, we miss the option to explain that you can filter by clicking on the charts (could help the discoverability problem)

What about introducing an html() option to define a different message if filtered or not?

dc.dataCount(".dc-data-count")
  .dimension(ndx)
  .group(all)
  .html ("%filter-count selected out of %total-count records | <a href="%filter-reset">Reset filters</a>"
   ,"%total-count records. Click on the graphs to filter them"
  );

so html (msg if filtered, msg if not filtered). %filter-count and %total-count and %filter-reset token
What do you think? should I add that? (hey, I almost can write tests too ;)

@gordonwoodhull

Hmm, it's a good idea but it's a pretty big change from the way things work right now, where it's just substituting in stuff by class (see e.g. baseChart.turnOnControls).

I guess the way to add the feature without disturbing the "order of things" would be to add more classes noreset, nocount, or something. So you would include two messages each for count and for reset and only one would show depending on the state.

I'm not sure if that is so great, though.

@tttp

We could keep the same logic by default so if you don't call html(), it still works the same as today and does the usual filter-count and al.

so no change if you call as today

dc.dataCount(".dc-data-count")
.dimension(ndx)
.group(all);

if you want the new behaviour, you have to explicitely call html()

dc.dataCount(".dc-data-count")
  .dimension(ndx)
  .html ();

That would be (without param) like
.html ("%filter-count selected out of %total-count records | Reset filters"
,"%total-count records. Click on the graphs to filter them")

Would it work for you?

@gordonwoodhull

It's a good idea. I guess it could be a little clearer if it took an object of messages, so:

.html ({some: "%filter-count selected out of %total-count records | Reset filters"}
,{all: "%total-count records. Click on the graphs to filter them"})

That way we could also have cases for zero and one, if desired. Would be glad to take a PR on this, or I'll get to it eventually.

@gordonwoodhull

Fixed via #619

@gordonwoodhull gordonwoodhull added this to the v2.0 milestone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.