2014-02-28 46 views
2

我是一個初學者與谷歌的可視化。我在獲取「interpolatingNulls:true」選項與AnnotationChart正常工作時遇到了問題。如果我使用與基本LineChart相同的數據集,它將按預期工作。這裏是我的代碼,並導致圖表:谷歌圖表 - interpolatingnulls選項不適用於AnnotationChart

<script type='text/javascript'> 
    google.load('visualization', '1.1', {'packages':['Annotationchart']}); 
    google.setOnLoadCallback(drawChart); 
    function drawChart() { 
    var data1 = new google.visualization.DataTable(<?=$json1?>); 
    var data2 = new google.visualization.DataTable(<?=$json2?>); 

    var joinedData = google.visualization.data.join(data1, data2, 'full', [[0, 0]], [1], [1]); 

    var chart1 = new google.visualization.AnnotationChart(document.getElementById('chart1')); 

    var options = { 
     displayAnnotations: false, 
    thickness: 2, 
    colors: ['red', 'blue'], 
    interpolateNulls: true, 
     curveType: 'function', 
    }; 

    chart1.draw(joinedData, options); 
    } 

生產:

http://imgur.com/r5sqtvd

鑑於:

<script type='text/javascript'> 
    google.load('visualization', '1', {'packages':['corechart']}); 
    google.setOnLoadCallback(drawChart); 
    function drawChart() { 
    var data1 = new google.visualization.DataTable(<?=$json1?>); 
    var data2 = new google.visualization.DataTable(<?=$json2?>); 

    var joinedData = google.visualization.data.join(data1, data2, 'full', [[0, 0]], [1], [1]); 

    var chart1 = new google.visualization.LineChart(document.getElementById('chart1')); 

    var options = { 
     displayAnnotations: false, 
    thickness: 2, 
    colors: ['red', 'blue'], 
    interpolateNulls: true, 
     curveType: 'function', 
    }; 

    chart1.draw(joinedData, options); 
    } 

生產:

http://imgur.com/qk79hob

我缺少什麼?

在此先感謝!

回答

2

AnnotationChart沒有選項interpolateNulls。請參閱google文檔Annotation Chart

+0

謝謝。我知道我錯過了一些簡單的東西。我正在考慮將此項目現在轉移到Dygraphs。 – casey2542

+1

您可以通過[ChartRangeFilter](https://developers.google.com/chart/interactive/docs/gallery/controls#chartrangefilter)和[Dashboard]中的LineChart獲取與AnnotationChart類似的功能(https:/ /developers.google.com/chart/interactive/docs/gallery/controls#dashboardobject)。 – asgallant

+0

謝謝,我會檢查出來。與此同時,我能夠獲得dygraphs的工作。花了一段時間來正確格式化數據,但它的工作,它看起來不錯! – casey2542