简体   繁体   English

ajax收集所有信息时的SVG指示器(D3.js)

[英]SVG indicator while ajax gather all information (D3.js)

I have a SVG (d3.js) visualization which takes some seconds to gather and render all necessary elements. 我有一个SVG(d3.js)可视化效果,需要花费几秒钟的时间来收集和渲染所有必要的元素。

Now I'd like to have some kind of loader image/text asking my user to wait until it is ready. 现在,我想要某种类型的加载程序图像/文本,要求我的用户等待它准备就绪。

I can do it using jQuery, externally of my SVG, but I'd like to "lock" my svg brush/etc and, somehow, only enable my visualization whenever it is ready ! 我可以在SVG的外部使用jQuery来做到这一点,但我想“锁定”我的svg笔刷/等,并且以某种方式仅在准备好时启用我的可视化功能! (whenever all async/sync ajax calls are done). (无论何时完成所有异步/同步ajax调用)。

Any insight is highly appreciated ! 任何见解都受到高度赞赏!

Cheers., 干杯。,

I would add an image on top of your canvas, which is hidden as soon as your SVG is loaded. 我会在画布顶部添加一个图像,该图像会在SVG加载后立即隐藏。 To determine when the SVG is loaded, try this code: 要确定何时加载SVG,请尝试以下代码:

function checkReady() {
    var svg = document.getElementById("svg-element").getSVGDocument();
    if (svg == null) {
        setTimeout("checkReady()", 300);
    } else {
        document.getElementById("svg-loading-img").style.display = "none";
    }
}

From this answer: https://stackoverflow.com/a/337383/1798148 从这个答案: https : //stackoverflow.com/a/337383/1798148

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

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