Skip to content

Commit

Permalink
restore legend.legendText documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonwoodhull committed Jul 19, 2016
1 parent 6ffc68d commit c5689fd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 2.0 Series
## 2.0.0 beta 32
* Improved implementation of alignYAxes, by Mohamed Gazal and Gordon Woodhull ([#1033](https://github.com/dc-js/dc.js/pull/1033))
* elasticY and elasticX did not work if all values were negative (coordinate grid and row charts, respectively), by Sebastian Gröhn ([#879](https://github.com/dc-js/dc.js/issues/879) / [#1156](https://github.com/dc-js/dc.js/pull/1156))
* Improved implementation of alignYAxes, by Mohamed Gazal and Gordon Woodhull ([#1033](https://github.com/dc-js/dc.js/pull/1033))
* Example of downloading the table data as it's formatted.
* `legend.legendText` documentation was missing.

## 2.0.0 beta 31
* Brush was sometimes not displaying, fix by Paul Briton ([#1134](https://github.com/dc-js/dc.js/issues/1134))
Expand Down
38 changes: 21 additions & 17 deletions src/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,26 +250,30 @@ dc.legend = function () {
};

/**
#### .legendText([legendTextFunction])
Set or get the legend text function. The legend widget uses this function to render
the legend text on each item. If no function is specified the legend widget will display
the names associated with each group.
Default: dc.pluck('name')
```js
// create numbered legend items
chart.legend(dc.legend().legendText(function(d, i) { return i + '. ' + d.name; }))
// create legend displaying group counts
chart.legend(dc.legend().legendText(function(d) { return d.name + ': ' d.data; }))
```
**/
_legend.legendText = function (_) {
* Set or get the legend text function. The legend widget uses this function to render the legend
* text for each item. If no function is specified the legend widget will display the names
* associated with each group.
* @method legendText
* @memberof dc.legend
* @instance
* @param {Function} [legendText]
* @return {Function}
* @return {dc.legend}
* @example
* // default legendText
* legend.legendText(dc.pluck('name'))
*
* // create numbered legend items
* chart.legend(dc.legend().legendText(function(d, i) { return i + '. ' + d.name; }))
*
* // create legend displaying group counts
* chart.legend(dc.legend().legendText(function(d) { return d.name + ': ' d.data; }))
**/
_legend.legendText = function (legendText) {
if (!arguments.length) {
return _legendText;
}
_legendText = _;
_legendText = legendText;
return _legend;
};

Expand Down

0 comments on commit c5689fd

Please sign in to comment.