lundi 15 décembre 2014

Chart Auto Adjustment



I have a chart (chart.js) on my sharepoint site (SP- 2013 Online), that is presenting data dynamically. Sometimes its a lot of data to show, then my Chart dont resize, i want the height to resize, depending on my data.


Heres my script so far, to make the height auto adjust, does anyone has a better solution?



for(var m = 0; m < data.length; m++){
height = height * 2;
if(data.length > 10){

height = height - 1;
}
}
function setChartDimensions() {
var width = 450;
// height = $(".bottomContent").offset().top - $("canvas").offset().top - 20;
if (currentChart) {
currentChart.chart.aspectRatio = width / height;
}
else {
$("canvas").attr("width", width);
$("canvas").attr("height", height);
}
}







0 commentaires:

Enregistrer un commentaire