Rendering a sparkline inside a datatable

Rendering a sparkline inside a datatable

joutwatejoutwate Posts: 3Questions: 0Answers: 0
edited January 2014 in DataTables 1.9
I've been trying to create a simple standalone datatable that renders a single column of sparklines. The first page renders fine however any subsequent page does not. I have looked at other posts similar to my issue however either I don't understand them or they weren't answered. Here's hoping someone can help out.

I appreciate any guidance.

Josh

[code]
<!DOCTYPE html>




@import "http://datatables.net/release-datatables/media/css/demo_page.css";
@import "http://datatables.net/release-datatables/media/css/jquery.dataTables.css";

td.right {
text-align: right;
}






$(document).ready(function () {
$('.spark').sparkline('html', {
type: 'line',
minSpotColor: 'red',
maxSpotColor: 'green',
spotColor: false
});

$('#dynamic').html('');
var table = $('#example').dataTable({
"aaSorting": [],
"aaData": [
["0,1,2,3,4"],
["4,3,2,1,0"],
["0,1,2,3,4"],
["4,3,2,1,0"],
["0,1,2,3,4"],
["4,3,2,1,0"],
["0,1,2,3,4"],
["4,3,2,1,0"],
["0,1,2,3,4"],
["4,3,2,1,0"],
["0,1,2,3,4"],
["4,3,2,1,0"]
],
"aoColumns": [
{ "sTitle": "Sparkline", "sClass": "center" }
],
"aoColumnDefs": [
{
"aTargets": [0],
"mRender": function (data, type, full) {
return '' + data + ''
}
}
],
"fnInitComplete": function (oSettings, json) {
$('.spark').sparkline('html', {
type: 'line',
minSpotColor: 'red',
maxSpotColor: 'green',
spotColor: false
});
}
});
});












[/code]

Replies

  • joutwatejoutwate Posts: 3Questions: 0Answers: 0
    I've started debugging the javascript and I'm no pro at this yet but I notice that call to sparkline in fnInitComplete is only looping over the sparklines that are visible and not all of them. Not sure if this is a problem with the sparkline code or intended and I'm missing something. Still no solution though...
  • joutwatejoutwate Posts: 3Questions: 0Answers: 0
    I've found the source of the problem and it has to do with the sparkline library. I'll take this issue to their forums.
This discussion has been closed.