HighCharts && DataTable
Author:Anusha
by Anusha ch
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<link rel="stylesheet" type="text/css"href="http://cdn.datatables.net/1.10.2/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css"href="http://cdn.datatables.net/tabletools/2.2.2/css/dataTables.tableTools.css">
<script src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<hr>
<br>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Fruits</th>
<th>Consumption</th>
<th>Age group</th>
<th>year</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Fruits</th>
<th>Consumption</th>
<th>Age group</th>
<th>year</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>John</td>
<td>Apples</td>
<td>5</td>
<td>61</td>
<td>2011/04/25</td>
</tr>
<tr>
<td>John</td>
<td>Oranges</td>
<td>4</td>
<td>61</td>
<td>2011/04/25</td>
</tr>
<tr>
<td>John</td>
<td>Pears</td>
<td>3</td>
<td>61</td>
<td>2011/04/24</td>
</tr>
<tr>
<td>John</td>
<td>Grapes</td>
<td>7</td>
<td>61</td>
<td>2011/04/21</td>
</tr>
<tr>
<td>John</td>
<td>2</td>
<td>Edinburgh</td>
<td>61</td>
...
JavaScript
$(document).ready(function() {
$('#example').DataTable();
} );
$(function () {
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Stacked column chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -30,
verticalAlign: 'top',
y: 25,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + this.y + '<br/>' +
'Total: ' + this.point.stackTotal;
}
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function () {
tableFilter(this.series.name,this.category,this.y);
}
}
}
},
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black'
}
}
}
},
...