Skip to content

Instantly share code, notes, and snippets.

@stla
Created September 11, 2013 20:37
Show Gist options
  • Select an option

  • Save stla/6529438 to your computer and use it in GitHub Desktop.

Select an option

Save stla/6529438 to your computer and use it in GitHub Desktop.
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css'>
<script src='http://code.jquery.com/jquery-1.10.2.min.js' type='text/javascript'></script>
<script src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
</style>
</head>
<body>
<table id='chart4442f192593' class='rChart datatables'></table>
<script type="text/javascript" charset="utf-8">
var chartParamschart4442f192593 = {
"dom": "chart4442f192593",
"width": 800,
"height": 400,
"table": {
"aaData": [
[
1,
0,
0,
0,
0
],
[
2,
0,
0,
0,
0
],
[
3,
0,
0,
0,
0
]
],
"aoColumnDefs": [
{
"sWidth": "10px",
"sTitle": "A",
"aTargets": [
0
]
},
{
"sWidth": "20px",
"sTitle": "B",
"aTargets": [
1
]
},
{
"sWidth": "30px",
"sTitle": "C",
"aTargets": [
2
]
},
{
"sWidth": "40px",
"sTitle": "D",
"aTargets": [
3
]
},
{
"sWidth": "50px",
"sTitle": "E",
"aTargets": [
4
]
}
],
"bAutoWidth": false
},
"id": "chart4442f192593"
}
$('#' + chartParamschart4442f192593.id).removeClass("rChart")
$(document).ready(function() {
drawDataTable(chartParamschart4442f192593)
});
function drawDataTable(chartParams){
var dTable = $('#' + chartParams.dom).dataTable(
chartParams.table
);
//first use rCharts width
$('#'+chartParams.id+"_wrapper").css("width",chartParams.width)
$('#'+chartParams.id+"_wrapper").css("width",chartParams.table.width)
//then if specified change to table width
$('#'+chartParams.id+"_wrapper").css("margin-left", "auto");
$('#'+chartParams.id+"_wrapper").css("margin-right", "auto");
dTable.fnAdjustColumnSizing();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment