Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 10 additions & 7 deletions modules/bar-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default class BarChart extends PureComponent {
lineData: [],
width: 400,
height: 200,
barWidth: 10,
axes: false,
xType: 'text',
yType: 'linear',
Expand Down Expand Up @@ -339,7 +338,7 @@ export default class BarChart extends PureComponent {
clickHandler,
colorBars,
xType,
barWidth
barWidth = 10
} = this.props;

const calculateDate = (v) => this.parseDate(v);
Expand All @@ -352,8 +351,8 @@ export default class BarChart extends PureComponent {
const calculateY = (d) => y(d.y);
const calculateW = () => (
(xType === 'text')
? x.bandwidth()
: barWidth);
? Math.max(x.bandwidth(), barWidth) : barWidth);

const calculateH = (d) => h - y(d.y);

const mouseover = (d) => mouseOverHandler(d, lastEvent);
Expand Down Expand Up @@ -463,16 +462,20 @@ export default class BarChart extends PureComponent {
yDomainRange,
margin,
width,
height
height,
barWidth
} = this.props;

const hasLineData = this.hasLineData();
const m = calculateMargin(axes, margin, yAxisOrientRight, hasLineData);
const w = reduce(width, m.left, m.right);
const calcWidth = (barWidth && data.length > 0) ?
Math.max((((barWidth + 1) * data.length) + m.left + m.right), width)
: width;
const w = reduce(calcWidth, m.left, m.right);

const h = reduce(height, m.top, m.bottom);
const x = this.createDomainRangeGenerator('x', xDomainRange, data, xType, w);
const y = this.createDomainRangeGenerator('y', yDomainRange, data, yType, h);

const node = this.createSvgNode({ m, w, h });
const root = this.createSvgRoot({ node, m });

Expand Down
8 changes: 0 additions & 8 deletions tests/bar-chart/bar-chart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@ describe('BarChart component', () => {
expect(chart.props).to.have.property('height', 200);
});

it('has a width for the bar on the chart', () => {
/**
* Bar Charts must have a non-zero width for the bars
* on the graph. We default to 10
*/
expect(chart.props).to.have.property('barWidth', 10);
});

it('has a pattern for formatting dates on the chart', () => {
/**
* We provide a pattern for formatting dates
Expand Down