Let plotly calculate the height based on provided margin values

This commit is contained in:
Kumar Vora
2016-05-09 16:11:51 -05:00
parent 303e158eb1
commit d2ba0cb6cf

View File

@@ -121,7 +121,6 @@
angular.module('plotly', []) angular.module('plotly', [])
.constant('ColorPalette', ColorPalette) .constant('ColorPalette', ColorPalette)
.directive('plotlyChart', function () { .directive('plotlyChart', function () {
var baseHeight = 250;
var bottomMargin = 50; var bottomMargin = 50;
return { return {
restrict: 'E', restrict: 'E',
@@ -165,7 +164,6 @@
scope.layout.showlegend = _.has(scope.options, 'legend') ? scope.options.legend.enabled : true; scope.layout.showlegend = _.has(scope.options, 'legend') ? scope.options.legend.enabled : true;
if(_.has(scope.options, 'bottomMargin')) { if(_.has(scope.options, 'bottomMargin')) {
bottomMargin = parseInt(scope.options.bottomMargin); bottomMargin = parseInt(scope.options.bottomMargin);
scope.layout.height = baseHeight + bottomMargin;
scope.layout.margin.b = bottomMargin; scope.layout.margin.b = bottomMargin;
} }
delete scope.layout.barmode; delete scope.layout.barmode;
@@ -289,7 +287,7 @@
scope.$watch('options', recalculateOptions, true); scope.$watch('options', recalculateOptions, true);
scope.layout = {margin: {l: 50, r: 50, b: bottomMargin, t: 20, pad: 4}, height: baseHeight+bottomMargin, autosize: true, hovermode: 'closest'}; scope.layout = {margin: {l: 50, r: 50, b: bottomMargin, t: 20, pad: 4}, autosize: true, hovermode: 'closest'};
scope.plotlyOptions = {showLink: false, displaylogo: false}; scope.plotlyOptions = {showLink: false, displaylogo: false};
scope.data = []; scope.data = [];