我有以下行,其中的列声明为 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.. 我不希望这种情况发生.. 如果我将平均值放在最旧和最新数据之间,它仍然是一个可选点,我也没有想?