Fixes #1195 Made the charts responsive for small screens

This commit is contained in:
gotens1211 2017-03-21 17:57:01 +05:30 committed by Stella Rouzi
parent f9d8c9715c
commit f4f05b4e9b
2 changed files with 36 additions and 1 deletions

View file

@ -1,6 +1,23 @@
.text-center
%h4 #{title}
%canvas.doughnut_chart{ 'data-chart' => data.to_json }
%canvas.doughnut_chart{ id: "dough_#{title}", 'data-chart' => data.to_json }
- if data
- data.each do |key, value|
%span{ 'style' => "border-bottom: 3px solid #{value['color']}" } #{key}: #{value['value']}
:javascript
$(document).ready( function(){
var d = $("#dough_#{title}");
var dt = d.get(0).getContext('2d');
$(window).resize( respondCanvas );
function respondCanvas(){
dt.canvas.width = 150;
dt.canvas.height = 150;
}
respondCanvas();
});