简体   繁体   English

禁用D3plus宽度更改动画

[英]Disable D3plus width change animation

I have to change dynamically the width of a D3plus chart, the problem is that the change in width is not instantaneous but there is an animation that scales the chart down or up accordingly, is there any way to disable this animation or all the eventual animation in general in D3plus? 我必须动态更改D3plus图表的宽度,问题是宽度的变化不是瞬时的,但是有一个动画可以相应地按比例缩小或放大图表,是否有任何方法可以禁用此动画或所有最终的动画通常在D3plus中?

This is the code i use: 这是我使用的代码:

var visualization = d3plus.viz()
            .container('#' + id)
            .data(data)
            .type('tree_map')
            .id('name')
            .size('value')
            .width($(window).width() - 85)
            .draw();

    $(window).on('orientationchange', function () {
        window.setTimeout(function () {
                visualization.width($(window).width() - 85).draw();
        }, 200);
    });

Have you looked at Transitions ? 您是否看过转场 Can't test without showing how are you changing the width atribute but if you set .transition(0) then it will update whatever you are changing (width or any style) instantly. 无法测试而不显示您如何更改width属性,但如果设置.transition(0) ,它将立即更新您所更改的任何内容(宽度或任何样式)。

With this JSFiddle if you change the value of .duration(3000) to .duration(0) [line 46] the animation dissapears. 使用此JSFiddle,如果将.duration(3000)的值更改为.duration(0)[第46行],动画将消失。

With animation: http://jsfiddle.net/k5rw9qr5/ 带有动画: http//jsfiddle.net/k5rw9qr5/

With .duration(0) : http://jsfiddle.net/pha367zu/1/ 使用.duration(0)http : //jsfiddle.net/pha367zu/1/

The D3plus documentation lists a .timing() method that can be modified. D3plus文档列出了可以修改的.timing()方法。 You would probably want to set the transition timing to zero: 您可能希望将过渡时间设置为零:

visualization.timing({"transitions": 0})

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

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