jQuery Flot慢&冻结IE [英] Jquery Flot Slow & freezes IE

查看:48
本文介绍了jQuery Flot慢&冻结IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前必须绘制大约8000-32000点(4行* 8000点)的图,我正在通过JSON请求获取数据,并且实际上可以完美地将数据在不到一秒钟的时间内返回给我.但是,每当我到达$ .plot点时,它就会冻结IE8,并永远需要花费很多时间才能加载该点.这是我的代码:

I currently have to plot in the neighborhood of 8000 - 32000 points (4 lines * 8000 points) I am getting my data via a JSON request and that works perfectly actually the data is returned to me in less than a second. However whenever I get to the $.plot point it freezes IE8 and it takes forever to load that many points. Here is my code:

var data = [];

        function onDataReceived(seriesData) {
            var p = $.plot(placeholder, seriesData.seriesData, options);
        }
        $.ajax({
            url: '/Charts/LineChart?DataTypesToGraph=' + dataTypes + '&DatePull=' + chartDate + '&AssetID=' + $('#AssetID').val(),
            method: 'GET',
            async: true,
            cache: true,
            dataType: 'json',
            success: onDataReceived
        });

如何加快$ .plot的加载速度呢?还有一种方法可以使它不会冻结IE8吗?

How can I speed up my $.plot to make it load a lot faster. Also is there a way I can do it so it does not freeze IE8?

非常感谢!

推荐答案

您看到的是冻结",因为Flot尚不支持增量绘图.在将控制权交还给浏览器之前,它将渲染整个图.除了破解代码,没有其他方法可以解决,但是您可以做两件事来帮助您:

You're seeing a 'freeze' because Flot doesn't (yet) support incremental drawing; it renders the entire plot before giving control back to the browser. There's no way around that besides hacking the code, but there are two things you can do to help:

  1. 您可能正在使用Excanvas;尝试切换到 Flashcanvas .以我的经验,它与Flot一样好用,并提供了明显更好的性能.许可专业版"所需的31美元不会超出大多数预算.

  1. You're probably using Excanvas; try switching to Flashcanvas. In my experience it works just as well with Flot, and delivers dramatically better performance. The $31 necessary to license the 'pro' version is not going to break most budgets.

每行有8000个点,大多数显示的最大宽度为1920像素,平均显示更像1280.如果要显示整行,而没有某种缩放/平移,则表示呈现的数据量比屏幕上实际显示的数据多4-6倍.一些服务器端过滤/聚合将点数降至2k,将大大提高性能.

You have 8000 points per line, and most displays max out at 1920 pixels wide, with the average being more like 1280. If you're showing the whole line, without some sort of zoom/pan, then you're rendering 4-6 times more data than is actually visible onscreen. Some server-side filtering/aggregation to bring the number of points down to 2k would dramatically improve performance.

但是,无论您做什么,都无法在具有大型数据集的IE8上获得出色的性能.这是一款使用了近四年历史的浏览器,是在JavaScript性能大战之前发布的,使用的是模拟画布.你只能做那么多.

But no matter what you do, you're never going to get great performance on IE8 with large datasets. It's an almost four-year-old browser, released before the JavaScript performance wars, using an emulated canvas; you can only do so much.

这篇关于jQuery Flot慢&冻结IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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