Skip to content

Commit

Permalink
fix graph labels (missing labels) and scale
Browse files Browse the repository at this point in the history
  • Loading branch information
pmusaraj committed Sep 27, 2016
1 parent afd5d40 commit a37fd9e
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions jsapp/js/components/reportViewItem.es6
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ var ReportViewItem = React.createClass({
chart_type = 'bar';
}

var max_percentage = Math.max.apply(Math, this.props.data.percentages);
max_percentage = max_percentage < 85 ? ((parseInt(max_percentage/10, 10)+1)*10) : 100;


var opts = {
type: chart_type,
data: {
Expand All @@ -130,14 +134,24 @@ var ReportViewItem = React.createClass({
scales: {
xAxes: [{
ticks: {
autoSkip:false,
beginAtZero: true,
max: 100
max: max_percentage
},
barPercentage: 0.5,
gridLines: {
display: chart_type == 'horizontalBar' ? true : false
}
}],
yAxes: [{
ticks: {
autoSkip:false,
beginAtZero: true,
max: 100
max: max_percentage
},
barPercentage: 0.5,
gridLines: {
display: chart_type == 'horizontalBar' ? false : true
}
}]
},
Expand All @@ -154,24 +168,6 @@ var ReportViewItem = React.createClass({
}
}

if (chart_type == 'bar') {
opts.options.scales.xAxes = [{
barPercentage: 0.4,
gridLines: {
display: false,
},
}];
}

if (chart_type == 'horizontalBar') {
opts.options.scales.yAxes = [{
barPercentage: 0.4,
gridLines: {
display: false,
}
}];
}

if (this.props.style.report_type == 'area') {
opts.data.datasets[0].backgroundColor = colors[0];
}
Expand Down

0 comments on commit a37fd9e

Please sign in to comment.