2014-04-15 3 views
1

스프레드 시트에 제공된 데이터로 차트를 그리려하고 있습니다. 첫 번째 문제는 JSON 피드 때문입니다.Google 스프레드 시트가있는 하이 스탁 차트 JSON

  1. Google Json 샘플에 키를 입력하면 아무 것도 표시되지 않습니다. 그러나 브라우저에 주소를 붙여 넣으면 JSON 피드가 명확하게 표시됩니다.

  2. 그런 다음 하이 차트 페이지의 예제 중 하나에 삽입하면로드되지 않습니다.

Fiddle Demo.

$(function() { 

    $.getJSON('https://spreadsheets.google.com/feeds/list/1zgfoS-vYXU_SKDyYEa2fUh6zIaluynibs75a2zZIclI/od6/public/values?alt=json-in-script&callback=?', function(data) 
    { 
     // Add a null value for the end date 
     data = [].concat(data, [[Date.UTC(2015, 9, 14, 19, 59), null, null, null, null]]); 

     // create the chart 
     $('#container').highcharts('StockChart', { 
      chart : { 
       type: 'spline', 
       zoomType: 'x' 
      }, 

      navigator : { 
       adaptToUpdatedData: false, 
       series : { 
        data : data 
       } 
      }, 

      scrollbar: { 
       liveRedraw: false 
      }, 

      title: { 
       text: 'AAPL history by the minute from 1998 to 2011' 
      }, 

      subtitle: { 
       text: 'Displaying 1.7 million data points in Highcharts Stock by async server loading' 
      }, 

      rangeSelector : { 
       buttons: [{ 
        type: 'hour', 
        count: 1, 
        text: '1h' 
       }, { 
        type: 'day', 
        count: 1, 
        text: '1d' 
       }, { 
        type: 'month', 
        count: 1, 
        text: '1m' 
       }, { 
        type: 'year', 
        count: 1, 
        text: '1y' 
       }, { 
        type: 'all', 
        text: 'All' 
       }], 
       inputEnabled: false, // it supports only days 
       selected : 4 // all 
      }, 

      xAxis : { 
       events : { 
        afterSetExtremes : afterSetExtremes 
       }, 
       minRange: 3600 * 1000 // one hour 
      }, 

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

/** * 선택한 분에 따라 새로운 데이터를로드 및 최대 */

function afterSetExtremes(e) { 

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

    chart.showLoading('Loading data from server...'); 
    $.getJSON('https://spreadsheets.google.com/feeds/list/1zgfoS-vYXU_SKDyYEa2fUh6zIaluynibs75a2zZIclI/od6/public/values?alt=json-in-script&callback=?', function(data) 
    { 
     chart.series[0].setData(data); 
     chart.hideLoading(); 
    }); 
} 
문제 또는 대안을 제공 뭐죠

누군가가 날 지점 수 있습니까?

답변

0

그런 식으로 이상한 개체가 있기 때문에 스프레드 시트에서 올바른 값을 참조해야합니다. 나는이 json을 파싱하여 배열, [x, y]를 얻거나 데이터에만 y 값을 반환합니다.

관련 문제