2017-07-29 58 views
2

我试图显示这个图表,有时在每一行都会有空值。我已经将“interpolatingNulls”添加到了我的选项中,但它仍然不起作用。是可能是一个简单的修复,但我卡住了。用谷歌图表插值Nulls

function drawChart() { 
    var data = new google.visualization.DataTable(); 
    data.addColumn('number', 'Day'); 
    data.addColumn('number', 'Guardians of the Galaxy'); 
    data.addColumn('number', 'The Avengers'); 
    data.addColumn('number', 'Transformers: Age of Extinction'); 

    data.addRows([ 
     [1, 37.8, 80.8, 41.8], 
     [2, 30.9, 69.5, 32.4], 
     [3, 25.4, 57, 25.7], 
     [4, 11.7, 18.8, 10.5], 
     [5, 11.9, 17.6, 10.4], 
     [6, 8.8, 13.6, 7.7], 
     [7, 7.6, 12.3, 9.6], 
     [8, 12.3, 29.2, 10.6], 
     [9, null, 42.9, null], 
     [10, 12.8, 30.9, 11.6], 
     [11, 5.3, 7.9, 4.7], 
     [12, 6.6, 8.4, 5.2], 
     [13, 4.8, 6.3, 3.6], 
     [14, 4.2, 6.2, 3.4] 
    ]); 

    var options = { 
     chart: { 
      title: 'Box Office Earnings in First Two Weeks of Opening', 
      subtitle: 'in millions of dollars (USD)', 
     }, 
     interpolateNulls: true, 
     width: 900, 
     height: 500 
    }; 

    var chart = new google.charts.Line(document.getElementById('linechart-material')); 
    chart.draw(data, google.charts.Line.convertOptions(options)); 
} 

回答

1

interpolateNulls材料支撑图表

材料的许多选项之一:google.charts.Line

看到 - >Tracking Issue for Material Chart Feature Parity


代替,建议使用经典图表,使用下列选项...

theme: 'material'

经典google.visualization.LineChart

+0

仔细查看资料图看起来很不错,但。我只需要编写自己的方法,我猜 –

+0

也有很多帮助。谢谢! –