我使用下面的鏈接,以創建一個漏斗圖與D3: jakezatecky/d3-funnel重寫D3漏斗圖的默認
的代碼工作正常。 現在,因爲它在教程中說,我要塊高度正比於自己的體重,所以我需要改變D3 deafult有:
D3Funnel.defaults.block.dynamicHeight = true;
,但是當我添加tihs一行到我的代碼整個圖表將消失。
您是否應該幫我找出問題所在? 代碼:
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="https://cdn.rawgit.com/jakezatecky/d3-funnel/0.3.2/d3-funnel.js?1"></script>
<input class="btn btn-primary" type="submit" id="submit_btn" value="Create Chart">
<br><br>
<div id="funnelPanel">
<div id="funnelContainer">
<div id="funnel"></div>
</div>
</div>
<script>
var data = [
["Clicked", "5,000"],
["Joined", "2,500"],
["Shared", "50"]
];
width = $('#funnelPanel').width();
var options = {
width: width - 300,
height: 400,
bottomPct: 1/4,
dynamicHeight: true,
fillType: "solid", // Either "solid" or "gradient"
hoverEffects: true // Whether the funnel has effects on hover
};
D3Funnel.defaults.block.dynamicHeight = true;
var funnel = new D3Funnel(data, options);
funnel.draw("#funnelContainer");
$(window).on("resize", function() {
var width = $("#funnelPanel").width();
options.width = width;
var funnel = new D3Funnel(data, options);
funnel.draw('#funnelContainer');
});
$('#submit_btn').on('click', function() {
var changed_data = [
["clicked", "3000"],
["joined", "70"],
["shared", "10"]
];
var funnel = new D3Funnel(changed_data, options);
funnel.draw('#funnelContainer');
});
</script>
貌似過時的文檔,我 –