I have a line chart, h-axis is date, v-axis is double. I need to display two lines:
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]
]
To display the data on the chart, I need to combine these two lines and pass the result to 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],
]
As a result of the above, I am getting gaps on the lines. How can I solve this issue? Is it possible to pass two individual sets, one for each line? All the examples I have found require them to be merged as the combine
table.
I need to keep the nulls when provided as part of line1 and line2 table
use the following option to fill in gaps created by null
values
interpolateNulls: true
EDIT
see following working snippet...
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>
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.