简体   繁体   English

具有大量数据的 HighChart 无法正常工作

[英]HighChart with large amount of data not working

I am working with one of the large CakePHP portal, where I have used Highcharts for some graphical representations.我正在使用大型 CakePHP 门户网站之一,我在其中使用 Highcharts 进行一些图形表示。

Its working fine for almost all the simple graphs, but my problem arise when Query retrieved large data from database and tried to plot in Highchart.它几乎适用于所有简单的图表,但是当 Query 从数据库中检索大数据并尝试在 Highchart 中使用 plot 时,我的问题就出现了。

Below are the example data which I tried to render in HighChart:以下是我尝试在 HighChart 中呈现的示例数据:

[series] => Array
        (
            [0] => Array
                (
                    [name] => Name 1
                    [data] => Array
                        (
                            [0] => 1080
                            [1] => 25
                            [2] => 0.92
                            [3] => 19.5
                            [4] => 0
                            [5] => 0
                            [6] => 0
                            [7] => 0
                            [8] => 0
                            [9] => 0
                            [...] => 0
                              .
                              .
                            [320] => 0
                         )
                     )
                     .
                     .
                     .
                     .
                     .

           [upto 400] => Array
                (
                    [name] => Name 2
                    [data] => Array
                        (
                            [0] => 250
                            [1] => 25
                            [2] => 0.92
                            [3] => 19.5
                            [4] => 0
                            [5] => 0
                            [6] => 0
                            [7] => 0
                            [8] => 0
                            [9] => 0
                            [...] => 0
                              .
                              .
                            [320] => 0
                         )
                    )
              )

But after loading for a long time page goes to white blank page.但是加载了很长一段时间后页面进入白色空白页面。

please have a look at below code.请看下面的代码。

It also allows zooming in both x and y.它还允许放大 x 和 y。

http://jsfiddle.net/DktpS/8/ http://jsfiddle.net/DktpS/8/

var isReset = false;

...

            xAxis: {
                events: {
                        afterSetExtremes : afterSetExtremes,
                    setExtremes: function (e) {


                        if (e.max == null || e.min == null) {
                           isReset = true;                            
                        }
                        else
                        {
                         isReset = false;   
                        }
                    }
                },
                minRange: 3600 * 1000 // one hour
            },

            series: [{
                data: data,
                dataGrouping: {
                    enabled: false
                }
            }]
        });
    });
});


    /**
     * Load new data depending on the selected min and max
     */
    function afterSetExtremes(e) {

        var url,
        currentExtremes = this.getExtremes(),
            range = e.max - e.min;
        var chart = $('#container').highcharts();

        var min = 0;
        var max = 1.35e12;
        if(!isReset)
        {
            min = e.min;
            max = e.max;
        }
         chart.showLoading('Loading data from server...');
        $.getJSON('http://www.highcharts.com/samples/data/from-sql.php?start=' + Math.round(min) +
            '&end=' + Math.round(max) + '&callback=?', function (data) {

            chart.series[0].setData(data);

            chart.hideLoading();


        });

    }

thanks谢谢

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

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