[英]Google charts, how do you add empty data into columns
我有以下行,其中的列聲明為null,當我沒有數據時它的值是...但它不能正確繪制圖形...我如何為列添加空數據以使行通過通過最后一個條目和當前條目之間的平均值?
function DrawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'a name');
data.addColumn('number', 'a name 2');
data.addColumn('number', 'a name 3');
data.addRows( [
[new Date( 2013, 7, 1 ),1.5,null,null],
[new Date( 2013, 6, 28 ),-1.5,null,null],
[new Date( 2013, 6, 21 ),null,-1,null],
[new Date( 2013, 6, 15 ),null,0,2],
[new Date( 2013, 6, 7 ),1.5,null,null],
[new Date( 2013, 6, 5 ),-1,null,null],
[new Date( 2013, 6, 1 ),0.5,2,null],
] );
// Set chart options
var options = {
'title': 'tracker',
'width': 800,
'height': 600,
'backgroundColor': 'transparent',
chartArea:
{
left: 'auto',
top: 'auto'
},
hAxis:
{
title: 'Date of bla',
titleTextStyle:
{
italic: false
},
gridlines:
{
color: "#E3E3E3"
},
showTextEvery: 1
},
vAxis:
{
title: 'Positivity',
titleTextStyle:
{
italic: false
},
gridlines:
{
color: "#E3E3E3"
}
}
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.LineChart( document.getElementById('chartDiv') );
google.visualization.events.addListener( chart, 'select', selectHandler );
chart.draw(data, options);
}
</script>
https://developers.google.com/chart/interactive/docs/reference#DataTable
輸入0而不是null表示數據將變為0。我不希望發生這種情況。如果將平均值放在最舊和最新的數據之間,那仍然是一個選擇點,我也不會想?
您想使用“ interpolateNulls”選項(在https://developers.google.com/chart/interactive/docs/gallery/linechart上描述)為“是否猜測缺失點的值。如果為true,它將猜測基於相鄰點的任何丟失數據的值。如果為false,則會在未知點的行中留下一個斷點。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.