"Hi everyone. I was wondering how I could pass, dynamically, jquery datatable values to highcharts from the code below. Variables like xAxis and the 2 yAxis". I do have more than 3 columns I should say, but not included here. mySql feed data to php who returns value as json format for datatable. Surely Highcharts can use this info without calling mysql again.
<thead>
<tr>
<th>Date</th>
<th>Generated kW</th>
<th>Efficiency %</th>
</tr>
</thead>
<script type="text/javascript">
$(document).ready(function() {
var table = $('#chartdaytable').dataTable({
"bProcessing": true,
"sAjaxSource": "../../php/ChartDayTable.php",
"bPaginate":true,
"sPaginationType":"full_numbers",
"iDisplayLength": 25,
"aaSorting": [[ 0, "desc" ]],
"aoColumns": [
{ mData: 'date' } ,
{ mData: 'day_energy' },
{ mData: 'efficiency' }
]
});
$('#chartgen').highcharts({
data: {
table: 'chartdaytable',
endColumn: 2,
},
chart: {
zoomType: 'xy',
},
xAxis: [{
//categories: 'some data',
}],
series: [{
name: 'Generation',
type: 'column',
yAxis: 0,
//data: 'some data',
}, {
name: 'Efficiency',
type: 'spline',
yAxis: 1,
//data: 'some data',
}]
});
});
</script>
This is example with static datatables. This will give some idea to get started. Check comment in snippet, if some doubt please comment
Fiddle Demonstration
Update This is server side sample which populate the chart after loading data in datatables.
JS code
HTML
Fiddle Demo