高图,5张小图,有些随机未绘制

时间:2018-09-10 13:19:18

标签: javascript highcharts

我在排行榜上遇到一些奇怪的问题。我连续有5个小图表,有时其中一两个随机不在屏幕上绘制。

这是我使用的代码

{"data":{
    "across_city": [
        {
            "name": "??",
            "rating": 0,
            "price": 0,
            "distance": 0,

        }
    ],
 "links": {
        "first": "",
        "last": "",
        "prev": null,
        "next": ""
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 3,
        "path": "",
        "per_page": 2,
        "to": 2,
        "total": 6
    },
{
    "near_by": [
        {
            "name": "??",
            "rating": 0,
            "price": 0,
            "distance": 0,

        }
    ],
 "links": {
        "first": "",
        "last": "",
        "prev": null,
        "next": ""
    },
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 3,
        "path": "",
        "per_page": 2,
        "to": 2,
        "total": 6
    }
}

我在做什么错?为什么有时第二,有时第五图表不显示?它让我疯狂。数据是静态的。

1 个答案:

答案 0 :(得分:1)

尝试像这样在每次渲染之间添加一些时间:

var new_followers = new Highcharts.Chart(twitter_hist_new_followers_options);
setTimeout(function(){
   var tweet_impressions = new Highcharts.Chart(twitter_hist_tweet_impressions_options);
}, 200);
setTimeout(function(){
    var number_of_tweets = new Highcharts.Chart(twitter_hist_number_of_tweets_options);
}, 400);
setTimeout(function(){
    var profile_visits = new Highcharts.Chart(twitter_hist_profile_visits_options);
}, 600);
setTimeout(function(){
    var hist_mentions = new Highcharts.Chart(twitter_hist_mentions_options);
}, 800);