2013-03-24 176 views
1

我创建了一个高图表和我从csv文件中获取的数据。图表运行良好并且绘图很好。但是我的问题是当页面刷新时没有从中取出最新值csv文件。它仍然显示旧的图表。当我关闭浏览器并重新打开图表工作正常。请帮助我如何重置/重绘更新的值从csv 下面是我的代码。此问题IE不能在Firefoxhighcharts当页面刷新时不刷新图表

变种选项= { 图表:{ renderTo: '容器', defaultSeriesType: '行', marginRight:130, marginBottom:25 }, 标题:{ 文本: '支持趋势P1,P2 & P3' }, XAXIS:{ 类:[] },

   yAxis: { 

        showLastLabel:true, 
        tickInterval:5, 
        title: { 
          text: "" 
        } 
        }, 

       series: [] 
      }; 


      $.get('../data/trending.txt', function(data) { 
       // Split the lines 
       var lines = data.split(';'); 
       $.each(lines, function(lineNo, line) { 
        var items = line.split(','); 

        // header line containes categories 
        if (lineNo == 0) { 
         $.each(items, function(itemNo, item) { 
          if (itemNo > 0) options.xAxis.categories.push(item); 
         }); 
        } 

        // the rest of the lines contain data with their name in the first position 
        else { 
         var series = { 
          data: [] 
         }; 
         $.each(items, function(itemNo, item) { 
          if (itemNo == 0) { 
           series.name = item; 
          } else { 
           series.data.push(parseFloat(item)); 
          } 
         }); 

         options.series.push(series); 

        } 

       }); 

       var chart = new Highcharts.Chart(options); 
      }); 


     }); 

块引用

+0

No code to see here? – SteveP 2013-03-24 13:14:10

+0

我的代码:HTTP://jsfiddle.net/r9Afj/4/embedded/result/ – arun 2013-03-24 15:08:49

+0

任何人知道答案 – arun 2013-03-24 16:52:17

回答

2

它看起来像你的图表数据被缓存,而不是由浏览器刷新。没有代码,知道如何解决它是一张卡片。

如果您正在使用jQuery $就,有一个选项

cache:false 

这可能有助于。 http://api.jquery.com/jQuery.ajax/

+0

我的代码:\t \t http://jsfiddle.net/r9Afj/4/embedded/result/ – arun 2013-03-24 15:09:10

+0

任何人都知道答案。请帮我解决 – arun 2013-03-24 16:51:53

+0

以上答案是正确的。您应该使用'$ .ajax()'而不是'$ .get()'并设置'cache:false'。 – 2013-03-25 11:44:01