我想第一次創建 D3 Js 甘特圖。我找到了一個很好的例子,它符合我的期望https://dk8996.github.io/Gantt-Chart/(Example2)。但是我在調??整 svg 大小時遇到??問題。我想將示例放入具有固定高度和寬度的 d3 容器中。該示例的按鈕可以復制/粘貼到我的代碼中。但是 SVG 總是在我的代碼/站點的底部生成。
<div class="Card-body">
<div id="d3-container">
//HERE
</div>
</div>
我嘗試了幾件事,但我只是不知道如何做到這一點。該示例始終占用整個螢屏。我怎樣才能做到這一點?
uj5u.com熱心網友回復:
甘特圖庫的 SVG 始終添加到檔案正文元素中。如果你想改變它,你需要替換https://github.com/dk8996/Gantt-Chart/blob/master/gantt-chart-d3.js檔案中的第 16 行和另外兩行(22 和 23)-例如將其下載到您的計算機并從您本地的 index.html 檔案中參考它,而不是從 Gannt-Chart 庫 URL - 到
var selector = '#d3-container';
...
var height = document.getElementById("d3-container").clientHeight - margin.top - margin.bottom-5;
var width = document.getElementById("d3-container").clientWidth - margin.right - margin.left-5;
以便在您的 DIV 容器中創建 SVG。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/354068.html
標籤:javascript html svg d3.js
上一篇:Uncaught(inpromise)TypeError:Cannotreadpropertiesofundefined(reading'0')--當所有物件都不是未定義時
下一篇:模板特化在C 中定義
