Skip to content

Commit

Permalink
Add block.hideLabel option
Browse files Browse the repository at this point in the history
Resolves #71.
  • Loading branch information
jakezatecky committed Jun 9, 2017
1 parent 30adf3a commit 854f858
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/d3-funnel/D3Funnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ class D3Funnel {
height: this.settings.height * ratio,
fill: this.colorizer.getBlockFill(block.backgroundColor, index, this.settings.fillType),
label: {
enabled: !block.hideLabel,
raw: block.label,
formatted: this.labelFormatter.format(block),
color: this.colorizer.getLabelColor(block.labelColor),
Expand Down Expand Up @@ -766,7 +767,7 @@ class D3Funnel {
});
}

if (this.settings.label.enabled) {
if (this.settings.label.enabled && block.label.enabled) {
this.addBlockLabel(group, index);
}
}
Expand Down
13 changes: 13 additions & 0 deletions test/d3-funnel/D3Funnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ describe('D3Funnel', () => {
assert.equal('Node C: Three', d3.select(texts[2]).text());
});

it('should hide the labels of any row specified', () => {
getFunnel().draw([
{ label: 'Node A', value: 1, hideLabel: true },
{ label: 'Node B', value: 2 },
{ label: 'Node C', value: 3, hideLabel: true },
]);

const texts = getSvg().selectAll('text').nodes();

assert.equal('Node B: 2', d3.select(texts[0]).text());
assert.equal(undefined, texts[1]);
});

it('should use colors assigned to a data element', () => {
getFunnel().draw([
['A', 1, '#111'],
Expand Down

0 comments on commit 854f858

Please sign in to comment.