'use strict';
module.exports = function (data_array, opts) {

	var barChar = require('figures').square;
	var Stats = require('fast-stats').Stats;
	var width = require('window-size').width;
	var maxBarWidth = width - 20;
	var total_sum = 0.;
	var percentage = [];
	var barWidths = [];

	for(var i in data_array){
		total_sum += data_array[i];
	}

	for(var i in data_array){
		percentage.push((data_array[i] / total_sum) * 100);
	}

	var max_percentage = (new Stats().push(percentage)).range()[1];

	var fixedLabels = new Array();
	var labelsTrue = opts ? opts.labels : false;
	var maxLabelLength = 0;

	if (labelsTrue) {
		for (var i in data_array) {
			maxLabelLength = (i.toString().length > maxLabelLength)
			? i.toString().length : maxLabelLength;
		}

		for (var i in data_array) {
			var padLength = maxLabelLength - i.toString().length + 1;
			fixedLabels.push(i + (padLength > 0
				? new Array(padLength).join(' ') : ''));
		}
	}

	maxBarWidth = labelsTrue ? (maxBarWidth - maxLabelLength) : maxBarWidth;

	for(var i in percentage){
		barWidths.push(Math.ceil(percentage[i] / max_percentage * maxBarWidth))
	}

	for(var i in percentage){
		console.log((labelsTrue ? fixedLabels[i] : '') + ' : '
		+ new Array(barWidths[i]).join(barChar) + ' '
		+ percentage[i].toFixed() + '%');
	}

};

@@ -278,24 +278,25 @@
  = %5B%5D;%0A%0A%09for
+ 
 (var i in da
@@ -300,24 +300,25 @@
  data_array)
+ 
 %7B%0A%09%09total_su
@@ -337,32 +337,33 @@
 ray%5Bi%5D;%0A%09%7D%0A%0A%09for
+ 
 (var i in data_a
@@ -367,16 +367,17 @@
 a_array)
+ 
 %7B%0A%09%09perc
@@ -1012,24 +1012,25 @@
 Width;%0A%0A%09for
+ 
 (var i in pe
@@ -1034,24 +1034,25 @@
  percentage)
+ 
 %7B%0A%09%09barWidth
@@ -1123,16 +1123,17 @@
 %09%7D%0A%0A%09for
+ 
 (var i i
@@ -1145,16 +1145,17 @@
 centage)
+ 
 %7B%0A%09%09cons

Fix coding style issues.