Skip to content

Commit

Permalink
excludeElasticZero flag for backward compatibility
Browse files Browse the repository at this point in the history
ref #1688
  • Loading branch information
gordonwoodhull committed Jun 19, 2020
1 parent 4e124c1 commit 1e66da5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/bubble-chart-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ describe('dc.bubbleChart', () => {
.valueAccessor(key_part(1))
.radiusValueAccessor(kv => kv.value.total)
.elasticRadius(true)
.excludeElasticZero(false)
.colors(d3.scaleOrdinal()
.domain(species.concat('none'))
.range(['#e41a1c','#377eb8','#4daf4a', '#f8f8f8']))
Expand Down
22 changes: 21 additions & 1 deletion src/base/bubble-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const BubbleMixin = Base => class extends ColorMixin(Base) {
this._minRadiusWithLabel = 10;
this._sortBubbleSize = false;
this._elasticRadius = false;
this._excludeElasticZero = true;

// These cane be used by derived classes as well, so member status
this.BUBBLE_NODE_CLASS = 'node';
Expand Down Expand Up @@ -104,7 +105,11 @@ export const BubbleMixin = Base => class extends ColorMixin(Base) {
}

rMin () {
return min(this.data().map(this.radiusValueAccessor()).filter(value => value > 0));
let values = this.data().map(this.radiusValueAccessor());
if(this._excludeElasticZero) {
values = values.filter(value => value > 0);
}
return min(values);
}

rMax () {
Expand Down Expand Up @@ -250,6 +255,21 @@ export const BubbleMixin = Base => class extends ColorMixin(Base) {
return this;
}

/**
* Should the chart exclude zero when calculating elastic bubble radius?
* @memberof BubbleMixin
* @instance
* @param {Boolean} [excludeZero=true]
* @returns {Boolean|BubbleMixin}
*/
excludeElasticZero (excludeZero) {
if (!arguments.length) {
return this._excludeElasticZero;
}
this._excludeElasticZero = excludeZero;
return this;
}

fadeDeselectedArea (selection) {
if (this.hasFilter()) {
const chart = this;
Expand Down

0 comments on commit 1e66da5

Please sign in to comment.