Skip to content

Commit

Permalink
Merge branch 'release/3.0.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonwoodhull committed Feb 1, 2019
2 parents ec83974 + cb91135 commit c2cfbb8
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 686 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.11
* Remove the deprecation on `colorMixin.colorCalculator`, and implement it in a reasonable way ([#1493](https://github.com/dc-js/dc.js/issues/1493))

## 3.0.10
This mostly updates examples and tests, and updates compatiblity polyfills for IE.
* Compatible with d3 5.8
Expand Down
27 changes: 15 additions & 12 deletions dc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dc.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dc",
"version": "3.0.10",
"version": "3.0.11",
"license": "Apache-2.0",
"copyright": "2017",
"description": "A multi-dimensional charting library built to work natively with crossfilter and rendered using d3.js ",
Expand Down
21 changes: 12 additions & 9 deletions src/color-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dc.colorMixin = function (_chart) {
var _defaultAccessor = true;

var _colorAccessor = function (d) { return _chart.keyAccessor()(d); };
var _colorCalculator;

/**
* Retrieve current color scale or set a new color scale. This methods accepts any function that
Expand Down Expand Up @@ -146,28 +147,30 @@ dc.colorMixin = function (_chart) {
* @returns {String}
*/
_chart.getColor = function (d, i) {
return _colors(_colorAccessor.call(this, d, i));
return _colorCalculator ? _colorCalculator.call(this, d, i) : _colors(_colorAccessor.call(this, d, i));
};

/**
* **Deprecated.** Get/set the color calculator. This actually replaces the
* {@link dc.colorMixin#getColor getColor} method!
* Overrides the color selection algorithm, replacing it with a simple function.
*
* This is not recommended, since using a {@link dc.colorMixin#colorAccessor colorAccessor} and
* color scale ({@link dc.colorMixin#colors .colors}) is more powerful and idiomatic d3.
* Normally colors will be determined by calling the `colorAccessor` to get a value, and then passing that
* value through the `colorScale`.
*
* But sometimes it is difficult to get a color scale to produce the desired effect. The `colorCalculator`
* takes the datum and index and returns a color directly.
* @method colorCalculator
* @memberof dc.colorMixin
* @instance
* @param {*} [colorCalculator]
* @returns {Function|dc.colorMixin}
*/
_chart.colorCalculator = dc.logger.deprecate(function (colorCalculator) {
_chart.colorCalculator = function (colorCalculator) {
if (!arguments.length) {
return _chart.getColor;
return _colorCalculator || _chart.getColor;
}
_chart.getColor = colorCalculator;
_colorCalculator = colorCalculator;
return _chart;
}, 'colorMixin.colorCalculator has been deprecated. Please colorMixin.colors and colorMixin.colorAccessor instead');
};

return _chart;
};
12 changes: 7 additions & 5 deletions web/docs/api-latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ such as [.svg](#dc.baseMixin+svg) and [.xAxis](#dc.coordinateGridMixin+xAxis),
return values that are themselves chainable d3 objects.

**Kind**: global namespace
**Version**: 3.0.10
**Version**: 3.0.11
**Example**
```js
// Example chaining
Expand Down Expand Up @@ -4729,11 +4729,13 @@ Get the color for the datum d and counter i. This is used internally by charts t
<a name="dc.colorMixin+colorCalculator"></a>

#### colorMixin.colorCalculator([colorCalculator]) ⇒ <code>function</code> \| [<code>colorMixin</code>](#dc.colorMixin)
**Deprecated.** Get/set the color calculator. This actually replaces the
[getColor](#dc.colorMixin+getColor) method!
Overrides the color selection algorithm, replacing it with a simple function.

This is not recommended, since using a [colorAccessor](#dc.colorMixin+colorAccessor) and
color scale ([.colors](#dc.colorMixin+colors)) is more powerful and idiomatic d3.
Normally colors will be determined by calling the `colorAccessor` to get a value, and then passing that
value through the `colorScale`.

But sometimes it is difficult to get a color scale to produce the desired effect. The `colorCalculator`
takes the datum and index and returns a color directly.

**Kind**: instance method of [<code>colorMixin</code>](#dc.colorMixin)

Expand Down
Loading

0 comments on commit c2cfbb8

Please sign in to comment.