Skip to content

Commit 71083e4

Browse files
Merge pull request #705 from contactashish13/issue-704
ChartJS chart does not follow pixel dimensions
2 parents b1482b2 + d646fce commit 71083e4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

js/render-chartjs.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,16 @@
127127
// chart area
128128
if(v.is_front == true){ // jshint ignore:line
129129
$('#' + id).css('position', 'relative');
130-
chartjs.canvas.parentNode.style.height = settings.height;
131-
chartjs.canvas.parentNode.style.width = settings.width;
130+
var height = settings.height.indexOf('%') === -1 ? ( settings.height + 'px' ) : settings.height;
131+
var width = settings.width.indexOf('%') === -1 ? ( settings.width + 'px' ) : settings.width;
132+
if(settings.height){
133+
chartjs.canvas.parentNode.style.height = height;
134+
$('#' + id + ' canvas').css('height', height);
135+
}
136+
if(settings.width){
137+
chartjs.canvas.parentNode.style.width = width;
138+
$('#' + id + ' canvas').css('width', width);
139+
}
132140
}
133141

134142
// allow user to extend the settings.

0 commit comments

Comments
 (0)