diff --git a/c3.js b/c3.js index b3d467f..5cb974b 100644 --- a/c3.js +++ b/c3.js @@ -332,7 +332,12 @@ main : function () { return "translate(" + margin.left + "," + margin.top + ")"; }, context : function () { return "translate(" + margin2.left + "," + margin2.top + ")"; }, legend : function () { return "translate(" + margin3.left + "," + margin3.top + ")"; }, - x : function () { return "translate(0," + (__axis_rotated ? 0 : height) + ")"; }, + x : function () { + if (__legend_show === true) { + return "translate(0," + (__axis_rotated ? 0 : height) + ")"; + } + return "translate(0," + (__axis_rotated ? 0 : height + margin3.top) + ")"; + }, y : function () { return "translate(0," + (__axis_rotated ? height : 0) + ")"; }, y2 : function () { return "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 1 : 0) + ")"; }, subx : function () { return "translate(0," + (__axis_rotated ? 0 : height2) + ")"; }, @@ -3811,7 +3816,7 @@ updateTargets(c3.data.targets); // Redraw with new targets - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: __legend_show}); if (typeof args.done === 'function') { args.done(); @@ -4157,7 +4162,7 @@ .style('opacity', 1); } - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: __legend_show}); }; c3.hide = function (targetIds, options) { @@ -4178,7 +4183,7 @@ .style('opacity', legendOpacityForHidden); } - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: __legend_show}); }; c3.toggle = function (targetId) { @@ -4224,7 +4229,7 @@ c3.unload = function (targetIds) { unload(mapToTargetIds(targetIds), function () { - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: __legend_show}); }); }; @@ -4448,21 +4453,21 @@ legend.style('visibility', 'visible'); } showLegend(mapToTargetIds(targetIds)); - redraw({withLegend: true}); + redraw({withLegend: __legend_show}); }; c3.legend.hide = function (targetIds) { - hideLegend(mapToTargetIds(targetIds)); - redraw({withLegend: true}); if (__legend_show && isEmpty(targetIds)) { __legend_show = false; legend.style('visibility', 'hidden'); } + hideLegend(mapToTargetIds(targetIds)); + redraw({withLegend: __legend_show}); }; c3.resize = function (size) { __size_width = size ? size.width : null; __size_height = size ? size.height : null; - updateAndRedraw({withLegend: true, withTransition: false, withTransitionForTransform: false}); + updateAndRedraw({withLegend: __legend_show, withTransition: false, withTransitionForTransform: false}); }; c3.destroy = function () {