I am trying to use jquery sparkline. THis is what I am trying to do.
var values = [{value:123}, {value:234}, {value:345}];
// Draw a sparkline for the #sparkline element
$('#sparkline').sparkline(values.value, {
type: "pie",
// Map the offset in the list of values to a name to use in the tooltip
tooltipFormat: '{{offset:offset}} ({{percent.1}}%)',
tooltipValueLookups: {
'offset': {
0: 'First',
1: 'Second',
2: 'Third'
}
},
});
but for this data format sparkline is not able to draw. what change I have to do in my code
You just have to extract values from your array before creating your sparkline.
You can use the .map
function :
$('#sparkline').sparkline(values.map(function(o) { return o.value}), {
...
});