Skip to content

Commit

Permalink
fixup adjust tick count for small values
Browse files Browse the repository at this point in the history
  • Loading branch information
Kelly Innes committed Aug 10, 2017
1 parent 8a046c3 commit 2ffae03
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/mmw/js/src/core/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ function renderCompareMultibarChart(chartEl, name, label, colors, stacked, data,
chart.width(chartEl.offsetWidth);
}

var yDomainMax = 1;
var yDomainMax = 1,
tickCount = 3;

if (!stacked) {
var maxValue = data.length ?
Expand All @@ -346,8 +347,16 @@ function renderCompareMultibarChart(chartEl, name, label, colors, stacked, data,
if (maxValue) {
yDomainMax = maxValue * 1.2;
}

if (maxValue <= 0.1) {
tickCount = 1;
}
} else {
yDomainMax = precipitation || 1;
if (precipitation) {
yDomainMax = precipitation;
} else {
tickCount = 1;
}
}

nv.addGraph(function() {
Expand All @@ -363,9 +372,11 @@ function renderCompareMultibarChart(chartEl, name, label, colors, stacked, data,
.id(name)
.yDomain([0, yDomainMax]);



chart.yAxis
.axisLabel(label)
.ticks(3)
.ticks(tickCount)
.showMaxMin(true);

chart.tooltip.enabled(false);
Expand Down

0 comments on commit 2ffae03

Please sign in to comment.