Skip to content

Commit

Permalink
Fixing up margins on a paired row chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhley committed Nov 19, 2015
1 parent 819f75c commit 7e71309
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 205 deletions.
77 changes: 11 additions & 66 deletions dc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dc.min.js.map

Large diffs are not rendered by default.

79 changes: 12 additions & 67 deletions src/paired-row-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,77 +131,22 @@ dc.pairedRowChart = function (parent, chartGroup) {
});
};

// width and margins

// the margins between the charts need to be set to 0 so that they sit together
var _margins = _chart.margins(); // get the default margins
_margins.right = _margins.left;

_chart.margins = function (_) {
if (!arguments.length) {
return _margins;
}
_margins = _;

// set left chart margins
_leftChart.margins({
top: _.top,
right: 0,
bottom: _.bottom,
left: _.left,
});

// set right chart margins
_rightChart.margins({
top: _.top,
right: _.right,
bottom: _.bottom,
left: 0,
});

return _chart;
// margins
var left_margins = _leftChart.margins;
var right_margins = _rightChart.margins;

_leftChart.margins = function() {
var margins = left_margins();
margins.right = 0;
return margins;
};

_chart.margins(_margins); // set the new margins

// the width needs to be halved
var _width = 0; // get the default width

_chart.width = function (_) {
if (!arguments.length) {
return _width;
}
_width = _;

// set left chart width
_leftChart.width(dc.utils.isNumber(_) ? _ / 2 : _);

// set right chart width
_rightChart.width(dc.utils.isNumber(_) ? _ / 2 : _);

return _chart;
_rightChart.margins = function() {
var margins = right_margins();
margins.left = 0;
return margins;
};

// the minWidth needs to be halved
var _minWidth = _chart.minWidth(); // get the default minWidth

_chart.minWidth = function (_) {
if (!arguments.length) {
return _minWidth;
}
_minWidth = _;

// set left chart minWidth
_leftChart.minWidth(dc.utils.isNumber(_) ? _ / 2 : _);

// set right chart minWidth
_rightChart.minWidth(dc.utils.isNumber(_) ? _ / 2 : _);

return _chart;
};

_chart.minWidth(_minWidth); // set the new minWidth

// svg
// return an array of both the sub chart svgs

Expand Down
77 changes: 11 additions & 66 deletions web/js/dc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/js/dc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/js/dc.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/js/dc.min.js.map

Large diffs are not rendered by default.

0 comments on commit 7e71309

Please sign in to comment.