[enhancement] Multiple lines on a linechart
Created by: slaapzakineentent
Started with this issue: #144 (closed)
In order to have 2 or more lines on a chart that don't have the same x axis values.
When you have more sources for your data is easier to make a dataTable for each dataset and merge/join them. Pass these as an array of dataTables to the Lava::LineChart('name', $tables[], $options[])
method. Right now this method only takes one table This would be for me cleaner code.
JavaScript example
original question
Now this wonderful plugin Lavacharts does not support this.
var joinedData = google.visualization.data.join(data1, data2, 'full', [[0, 0]], [1], [1]);
var chart = new google.visualization.LineChart(document.querySelector('#chart_div'));
chart.draw(joinedData, {
interpolateNulls: true
});
This does the magic.
When we pass a array of tables we should automatically add the interpolateNulls: true
to the options (correct me if I'm wrong).
We also need to add somewhere the other parameters, 'full' could be in the options array, but I have no idea yet how to pass the other arrays.
More info on these parameters: Google documentation
I don't know how you are going to implement this, you might use the Javascript method or make the merge yourself in php. When you make it in php it is not necessary to have any trailing null
.
php $table->addRow(array('2016-2-1 11:02:45', 10, null));
equals
php $table->addRow(array('2016-2-1 11:02:45', 10));