Google 可视化折线图 - 多条线
Google Visualisation Line Chart - Multiple Lines
我有一个折线图,h轴是日期,v轴是双。
我需要显示两行:
lineA: [
[2016-1-1 00:00, 1.1]
[2016-2-1 00:00, 1.1]
[2016-3-1 00:00, 1.1]
]
lineB: [
[2016-1-1 00:00, 2.1]
[2016-2-1 08:00, 2.1]
[2016-3-1 00:00, 2.1]
]
要在图表上显示数据,我需要合并这两行并将结果传递给 arrayToDataTable。
combine: [
[2016-1-1 00:00, 1.1, 2.1],
[2016-2-1 00:00, 1.1, null],
[2016-2-1 08:00, null, 2.1],
[2016-3-1 00:00, 1.1, 2.1],
]
由于上述原因,我的线条出现了空白。我该如何解决这个问题?是否可以通过两个单独的集合,每行一个?我发现的所有示例都要求将它们合并为 combine
table.
I need to keep the nulls when provided as part of line1 and line2
table
使用以下选项来填补 null
值
造成的空白
interpolateNulls: true
编辑
请参阅以下工作片段...
google.charts.load('current', {
callback: function () {
var data = google.visualization.arrayToDataTable([
[new Date(2016, 0, 1), 1.1, 2.1],
[new Date(2016, 1, 1), 1.1, null],
[new Date(2016, 1, 1, 8), null, 2.1],
[new Date(2016, 2, 1), 1.1, 2.1]
], true);
var options = {
interpolateNulls: true
};
var container = document.body.appendChild(document.createElement('div'));
var chart = new google.visualization.LineChart(container);
chart.draw(data, options);
},
packages: ['corechart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>
我有一个折线图,h轴是日期,v轴是双。 我需要显示两行:
lineA: [
[2016-1-1 00:00, 1.1]
[2016-2-1 00:00, 1.1]
[2016-3-1 00:00, 1.1]
]
lineB: [
[2016-1-1 00:00, 2.1]
[2016-2-1 08:00, 2.1]
[2016-3-1 00:00, 2.1]
]
要在图表上显示数据,我需要合并这两行并将结果传递给 arrayToDataTable。
combine: [
[2016-1-1 00:00, 1.1, 2.1],
[2016-2-1 00:00, 1.1, null],
[2016-2-1 08:00, null, 2.1],
[2016-3-1 00:00, 1.1, 2.1],
]
由于上述原因,我的线条出现了空白。我该如何解决这个问题?是否可以通过两个单独的集合,每行一个?我发现的所有示例都要求将它们合并为 combine
table.
I need to keep the nulls when provided as part of line1 and line2 table
使用以下选项来填补 null
值
interpolateNulls: true
编辑
请参阅以下工作片段...
google.charts.load('current', {
callback: function () {
var data = google.visualization.arrayToDataTable([
[new Date(2016, 0, 1), 1.1, 2.1],
[new Date(2016, 1, 1), 1.1, null],
[new Date(2016, 1, 1, 8), null, 2.1],
[new Date(2016, 2, 1), 1.1, 2.1]
], true);
var options = {
interpolateNulls: true
};
var container = document.body.appendChild(document.createElement('div'));
var chart = new google.visualization.LineChart(container);
chart.draw(data, options);
},
packages: ['corechart']
});
<script src="https://www.gstatic.com/charts/loader.js"></script>