Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Commit

Permalink
Fixed min non zero height calc
Browse files Browse the repository at this point in the history
  • Loading branch information
victorkirov committed Feb 21, 2017
1 parent d60eae9 commit fe8f362
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/chart/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class BarChart extends Component {
renderItems(items, xAxisMap, yAxisMap, offset, stackGroups) {
if (!items || !items.length) { return null; }

const { layout } = this.props;
const { layout, height } = this.props;
const sizeList = this.getSizeList(stackGroups);
const { animationId, minNonZeroValueHeight } = this.props;

Expand Down Expand Up @@ -303,14 +303,18 @@ class BarChart extends Component {
items.push(_.get(barData, `[${i}][${key}]`))
}

_.map(items, (item) => {
totalHeight += item.height
})

const localMinNonZeroValueHeight = minNonZeroValueHeight / height * totalHeight

_.map(items, (item) => {
const itemHeight = item.height

if (itemHeight === 0) return

totalHeight += itemHeight

if (minNonZeroValueHeight > itemHeight) {
if (localMinNonZeroValueHeight > itemHeight) {
rowsToChange++
}
else {
Expand All @@ -328,11 +332,11 @@ class BarChart extends Component {

if (itemHeight === 0) return

if (minNonZeroValueHeight > itemHeight) {
item.height = minNonZeroValueHeight
deltaY += minNonZeroValueHeight - itemHeight
if (localMinNonZeroValueHeight > itemHeight) {
item.height = localMinNonZeroValueHeight
deltaY += localMinNonZeroValueHeight - itemHeight
} else {
item.height = (totalHeight - minNonZeroValueHeight * rowsToChange) / heightOfRemaining * itemHeight
item.height = (totalHeight - localMinNonZeroValueHeight * rowsToChange) / heightOfRemaining * itemHeight
deltaY += item.height - itemHeight
}

Expand Down

0 comments on commit fe8f362

Please sign in to comment.