Skip to content

Commit

Permalink
Merge pull request uber#106 from uber/fix-105
Browse files Browse the repository at this point in the history
fix rendering of bar charts with ordinal scales
  • Loading branch information
jckr authored Jun 11, 2016
2 parents 87fe294 + 0d2dfa9 commit f2f8508
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/example/plot/bar-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default class Example extends React.Component {
render() {
return (
<XYPlot
xType="ordinal"
width={300}
height={300}>
<VerticalGridLines />
Expand All @@ -40,15 +41,15 @@ export default class Example extends React.Component {
<YAxis />
<VerticalBarSeries
data={[
{x: 1, y: 10},
{x: 2, y: 5},
{x: 3, y: 15}
{x: 'A', y: 10},
{x: 'B', y: 5},
{x: 'C', y: 15}
]}/>
<VerticalBarSeries
data={[
{x: 1, y: 12},
{x: 2, y: 2},
{x: 3, y: 11}
{x: 'A', y: 12},
{x: 'B', y: 2},
{x: 'C', y: 11}
]}/>
</XYPlot>
);
Expand Down
6 changes: 5 additions & 1 deletion src/lib/utils/scales-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ function _getScaleFnFromScaleObject(scaleObject) {
return null;
}
const {type, domain, range} = scaleObject;
return SCALE_FUNCTIONS[type]().domain(domain).range(range);
const scale = SCALE_FUNCTIONS[type]().domain(domain).range(range);
if (type === ORDINAL_SCALE_TYPE) {
scale.padding(0.5);
}
return scale;
}

/**
Expand Down

0 comments on commit f2f8508

Please sign in to comment.