同时发生的数据减慢了应用程序的速度 [英] Simultaneous data slows down the application

查看:97
本文介绍了同时发生的数据减慢了应用程序的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是我有5个不同的图表,它们会同时加载随机生成的数据,导致应用程序运行缓慢。应用程序的要点是让用户选择一次他想查看的图表,其他所有图表应该空闲(情况并非如此)......

The problem I am encountering is that I have 5 different diagrams that load the random generated data simultaneously causing the application to run slow. The point of the application is to let the user select which diagram he wants to view once, and all the other diagrams should be idle (this is not the case)...

我开始相信,因为我在index.html中包含了图表(diagram1.js,diagram2.js等),这可能是应用程序变慢的原因,因为所有内容都会加载一旦。我只使用JQuery来显示或隐藏取决于点击的图表。

I am starting to believe that because I have included the diagrams (diagram1.js, diagram2.js etc) in index.html, that this could be why the application slows down, because everything loads at once. I am using JQuery only to show or hide the diagram depended on the clicks.

如何让用户只看到一个图表,并保持其他空闲状态(没有传入数据),直到他们被选中?

这包含在index.html中,位于< body> 内,< div id =diagram4>< / div> 负责显示图表。

This is included in index.html, inside <body>, <div id = "diagram4"></div> is responsible for showing the diagram.

<script src="diagram1.js"></script>
<script src="diagram2.js"></script>
<script src="diagram3.js"></script>
<script src="diagram4.js"></script>
<script src="diagram5.js"></script>

这是包含图表内容的图表4.js,请记住,我没有包含整个代码以节省本文档中的空间。

This is diagram4.js that holds the diagram content, keep in mind that I have not included the whole code to save space in this document.

$(window).on("load", function() {
        var chart = new CanvasJS.Chart("diagram4",
        { 
           // Code.. 
        }); 
});

这是处理点击的JQuery事件。当用户点击图表4时,弹出图表4。

This is JQuery event that handles the click. When the user clicks on diagram4, then diagram4 pops up.

    $('[data-row]').on('click', function() {
        var row = $(this).attr('data-row');
         $('.active').removeClass('active');
         $('#table' + row).addClass('active');
    });


推荐答案

$(window).on(load,...))你可以提供4个div或类似的附加的onclick处理程序,它可以在点击时渲染图。您可以在div中放置一些信息文本甚至符号图。

Instead of creating all diagrams when the page is loaded ($(window).on("load", ...)) you can provide 4 divs or the like with attached onclick handlers which would render a diagram when clicked. You can put some info text or even a symbolic picture of the diagram in the div.

这篇关于同时发生的数据减慢了应用程序的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆