javascript - Responsive Chart.js Doughnut Chart with minimum height -
i've been trying find nice looking doughnut chart thats responsive , came across chart.js
however, having hard time getting doughnut chart big want it.
does know how can make have minimum height? i'd love hear suggestions.
my goal have fill red div both height , width wise. @ moment, have: 
i'm using bootstrap grid
<div class="col-sm-4" style="border:1px solid red;height:350px"> <canvas id="weekly_doughnut_data"></canvas> </div> <div class="col-sm-8"> <canvas id="weekly_line_data"></canvas> </div> javascript
var weekly_doughnut_data = [ { value: 1, color:"#53a3eb", highlight: "#53a3eb", label: "simple" }, { value: 3, color: "#34495e", highlight: "#34495e", label: "advanced" }]; var weekly_doughnut_ctx = document.getelementbyid("weekly_doughnut_data").getcontext("2d"); var weekly_doughnut_chart = new chart(weekly_doughnut_ctx).doughnut(weekly_doughnut_data,{percentageinnercutout : 90, responsive: true}); i've tried resize function set height myself, get's glitchy (on mouseover) , slow.
$(window).resize(function() { weekly_doughnut_ctx.canvas.height = $(".canvas_holder").height(); weekly_doughnut_chart = new chart(weekly_doughnut_ctx).doughnut(weekly_doughnut_data,{percentageinnercutout : 90, responsive: true}); //weekly_doughnut_chart.resize(); //weekly_doughnut_chart.redraw(); });
i wasn't able "solve" per say. appears happening red bordered div small responsive chart appropriate size div width think?
what ended doing putting charts (responsive mode on) in 2 bootstrap columns , ended doing looking nice.
<div id="circle_chart" class="col-md-5"><canvas></canvas></div> <div id="chart_container" class="col-md-7"><canvas></canvas></div> on window resize, did end calculating height of circle_chart , adding margin of 50% height , subtracting height of chart_container centered other graph.
$("#circle_chart").css("margin-top", (($("#chart_container").height()-$("#circle_chart").height())/2)+"px");
Comments
Post a Comment