Skip to content

Commit

Permalink
[#70] add data count widget api
Browse files Browse the repository at this point in the history
  • Loading branch information
NickQiZhu committed Dec 3, 2012
1 parent e6607c8 commit 7a0c34a
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions wiki.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The entire dc.js library is scoped under **dc** name space. It does not introduc
* [Bubble Chart [concrete] < Abstract Bubble Chart < CoordinateGrid Chart](#bubble-chart)
* [Bubble Overlay Chart [concrete] < Abstract Bubble Chart < Base Chart](#bubble-overlay-chart)
* [Geo Choropleth Chart [concrete] < Single Selection Chart < Color Chart < Base Chart](#geo-choropleth-chart)
* [Data Count Widget [concrete] < Base Chart](#data-count)

### Function Chain
Majority of dc functions are designed to allow function chaining, meaning it will return the current chart instance
Expand Down Expand Up @@ -581,7 +582,7 @@ coloring.
Examples:
* [Canadian City Crime Stats](http://nickqizhu.github.com/dc.js/crime/index.html)

#### .dc.bubbleOverlay(parent[, chartGroup])
#### dc.bubbleOverlay(parent[, chartGroup])
Create a bubble overlay chart instance and attach it to the given parent element.

Parameters:
Expand Down Expand Up @@ -623,7 +624,7 @@ chart implementation was inspired by [the great d3 choropleth example](http://bl
Examples:
* [US Venture Capital Landscape 2011](http://nickqizhu.github.com/dc.js/vc/index.html)

#### .dc.geoChoroplethChart(parent[, chartGroup])
#### dc.geoChoroplethChart(parent[, chartGroup])
Create a choropleth chart instance and attach it to the given parent element.

Parameters:
Expand Down Expand Up @@ -663,3 +664,40 @@ chart.overlayGeoJson(statesJson.features, "state", function(d) {
Set custom geo projection function. Available [d3 geo projection functions](https://github.com/mbostock/d3/wiki/Geo-Projections).
Default value: albersUsa.

## <a name="data-count" href="#data-count">#</a> Data Count Widget [Concrete] < [Base Chart](#base-chart)
Data count is a simple widget designed to display total number records in the data set vs. the number records selected
by the current filters. Once created data count widget will automatically update the text content of the following elements
under the parent element.

* ".total-count" - total number of records
* ".filter-count" - number of records matched by the current filters

Examples:
* [Nasdaq 100 Index](http://nickqizhu.github.com/dc.js/)

#### dc.dataCount(parent[, chartGroup])
Create a data count widget instance and attach it to the given parent element.

Parameters:
* parent : string - any valid d3 single selector representing typically a dom block element such as a div.
* chartGroup : string (optional) - name of the chart group this chart instance should be placed in. Once a chart is placed
in a certain chart group then any interaction with such instance will only trigger events and redraw within the same
chart group.

Return:
A newly created data count widget instance

#### .dimension(allData) - **mandatory**
For data count widget the only valid dimension is the entire data set.

#### .group(groupAll) - **mandatory**
For data count widget the only valid group is the all group.

```js
var ndx = crossfilter(data);
var all = ndx.groupAll();

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

0 comments on commit 7a0c34a

Please sign in to comment.