@data-ui/xy-chart
Version:
A package of charts with standard x- and y- axes. https://williaster.github.io/data-ui
16 lines (13 loc) • 782 B
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import { DEFAULT_CHART_MARGIN } from './chartUtils';
export default function getChartDimensions(_ref) {
var margin = _ref.margin,
width = _ref.width,
height = _ref.height;
var completeMargin = _extends({}, DEFAULT_CHART_MARGIN, margin);
return {
margin: completeMargin,
innerHeight: Math.max(0, height - completeMargin.top - completeMargin.bottom),
innerWidth: Math.max(0, width - completeMargin.left - completeMargin.right)
};
}