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

exposes emptyOpacity, emptyColor for scatterplot #1058

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions src/scatter-plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ dc.scatterPlot = function (parent, chartGroup) {
var _symbolSize = 3;
var _highlightedSize = 5;
var _hiddenSize = 0;
var _hiddenOpacity = 0;
var _hiddenColor = 'grey';

_symbol.size(function (d) {
if (!_existenceAccessor(d)) {
return _hiddenSize;
return Math.pow(_hiddenSize, 2);
} else if (this.filtered) {
return Math.pow(_highlightedSize, 2);
} else {
Expand Down Expand Up @@ -72,7 +74,7 @@ dc.scatterPlot = function (parent, chartGroup) {
.attr('transform', _locator);

dc.transition(symbols, _chart.transitionDuration())
.attr('opacity', function (d) { return _existenceAccessor(d) ? 1 : 0; })
.attr('opacity', function (d) { return _existenceAccessor(d) ? 1 : _hiddenOpacity; })
.attr('fill', _chart.getColor)
.attr('transform', _locator)
.attr('d', _symbol);
Expand Down Expand Up @@ -185,6 +187,40 @@ dc.scatterPlot = function (parent, chartGroup) {
return _chart;
};

/**
* Set or get color for symbols when the group is empty.
* @name hiddenColor
* @memberof dc.scatterPlot
* @instance
* @param {String} [hiddenColor='grey']
* @return {String}
* @return {dc.scatterPlot}/
*/
_chart.hiddenColor = function (hiddenColor) {
if (!arguments.length) {
return _hiddenColor;
}
_hiddenColor = _hiddenColor;
return _chart;
};

/**
* Set or get opacity for symbols when the group is empty.
* @name hiddenOpacity
* @memberof dc.scatterPlot
* @instance
* @param {Number} [hiddenOpacity=0]
* @return {Number}
* @return {dc.scatterPlot}
*/
_chart.hiddenOpacity = function (hiddenOpacity) {
if (!arguments.length) {
return _hiddenOpacity;
}
_hiddenOpacity = hiddenOpacity;
return _chart;
};

_chart.legendables = function () {
return [{chart: _chart, name: _chart._groupName, color: _chart.getColor()}];
};
Expand Down