简体   繁体   English

我想使用图表来可视化数据。由于我使用的D3js没有响应,因此需要一些建议

[英]I want to use charts and graphs for visualizing data.Need some recommendation as D3js that I am using is not responsive

Are there any open source frameworks to visualize data in mostly Bullet charts/Gantt charts/ Bar charts and line charts. 是否有任何开放源代码框架可以使大部分项目符号图/甘特图/条形图和折线图中的数据可视化。 I am using d3.js right now but it is not responsive. 我现在正在使用d3.js,但它没有响应。 Is there any other frameworks which can give me all above charts and also need to be responsive or is there any way to make D3 responsive. 是否有其他框架可以为我提供上述所有图表,并且还需要响应能力,或者是否有任何方法可以使D3响应。

I know 2 ways to make D3 responsive: 我知道使D3响应的2种方法:

1) check the window resize event. 1)检查窗口调整大小事件。 Basically, when the window resizes, you delete your charts and you redraw them based on the new dimensions. 基本上,当窗口调整大小时,您将删除图表,然后根据新尺寸重新绘制它们。

d3.select(window).on("resize",resize);

        function resize() {
            /* resetting the entire visualisation, the svg's and other added elements */
            d3.selectAll("svg").remove();
            d3.selectAll(".graphline").remove();
            d3.select("#namerow").remove();

            *function to redraw everthing*
        }

In your draw function, you can capture the width of the window as following: 在绘图功能中,您可以捕获窗口的宽度,如下所示:

var chartWidth = parseInt(divParentContainer.style("width"),10);
var chartHeight = chartWidth * 0.8; // 0.8 can be seen as width-height ratio

2) check the answer on this page . 2)检查此页面上的答案。 In my personal opinion, that way is the easiest one. 我个人认为,这是最简单的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM