It will never fit perfectly because multiples of count * (width + spacing)
may never fill the width exactly because they are rounded to integer values.
Best approximation I use now looks like that. (There is some additional code which reads the settings from data attributes.)
var $el = $(el);
var values = $el.data('values').split(',').map(parseFloat);
var type = $el.data('type') || 'line' ;
var height = $el.data('height') || 'auto';
var parentWidth = $el.parent().width();
var valueCount = values.length;
var barSpacing = 1;
var barWidth = Math.round((parentWidth - ( valueCount - 1 ) * barSpacing ) / valueCount);
$el.sparkline(values, {width:'100%', type: type, height: height, barWidth: barWidth, barSpacing: barSpacing});
The only optimisation left would be playing with the barSpacing
parameter to reduce the difference between the product of the rounded barWidths and the parent width.