Skip to content

Commit

Permalink
fixed c3 chart height and width issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Bibhas committed Aug 31, 2016
1 parent 82db61a commit 9d7f51e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test.db
*.wpr
.project
.pydevproject
.vscode
.settings
.sass-cache
.webassets-cache
Expand Down
2 changes: 1 addition & 1 deletion hasjob/models/jobpost.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def viewstats_helper(jobpost_id, interval, limit, daybatch=False):
for delta in range(batches):
if daybatch:
# here delta=0, so last item is the latest date/hour
cbuckets[batches - delta - 1] = (now_local - timedelta(days=delta)).strftime("%d-%m-%Y")
cbuckets[batches - delta - 1] = (now_local - timedelta(days=delta)).strftime("%b %d")
else:
from_hour = (now_local - timedelta(hours=delta)).strftime("%H:00")
to_hour = (now_local - timedelta(hours=delta - 1)).strftime("%H:00")
Expand Down
9 changes: 7 additions & 2 deletions hasjob/templates/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ <h2>A/B test results</h2>
c3.generate({
bindto: '#viewstats-chart',
size: {
height: 150
height: 200
},
data: {
type: 'spline',
Expand All @@ -487,14 +487,19 @@ <h2>A/B test results</h2>
},
axis: {
x: {
type: 'category'
type: 'category',
height: 50
},
y: {
tick: { format: d3.format("d") }
}
}
});
$('#viewstats').removeClass('hidden');
// c3 initially draws the width too big,
// a window resize event forces it to redraw the chart properly
// http://stackoverflow.com/a/27180464/257944
$(window).trigger('resize');
})
}
{%- endif %}
Expand Down

0 comments on commit 9d7f51e

Please sign in to comment.