使用视图框调整SVG D3日历的大小 - 使其看起来很漂亮

时间:2016-05-26 00:28:21

标签: javascript d3.js svg viewbox

调整大小时,我很难让它看起来很漂亮。 我确定父/子大小与我不理解的方面之间存在某种逻辑关系。如果有人能给我一些指示,我将不胜感激。

<script src="javascript.js"</script>

1 个答案:

答案 0 :(得分:0)

每次调整窗口大小时,只需动态获取viewBox,而不是preserveAspectRatio上的$(window).resizeparent height and width出汗:

 var containerWidth = $("#yourChartId").parent().width(); // gets immediate parent width
 var containerheight = $("#yourChartId").parent().height();// gets immediate parent height
 var margin = {top: 15, right: 15, bottom: 20, left: 40},
 width = containerWidth- margin.left - margin.right,
 height = containerheight - margin.top - margin.bottom;