d-grouped-barchart
Advanced tools
Comparing version 0.0.16 to 0.0.17
20
index.js
@@ -131,2 +131,8 @@ var d3 = require('d3'); | ||
var total = d3.sum(data, function(d) { | ||
return d3.sum(d.properties, function(d) { | ||
return d.value; | ||
}); | ||
}); | ||
// Get the x axis position (handle negative values) | ||
@@ -155,2 +161,3 @@ this.xAxisTransform = height | ||
this.maxVal = maxVal; | ||
this.total = total; | ||
} | ||
@@ -175,2 +182,6 @@ | ||
var legendConfig = this.legendConfig; | ||
var tipConfig = model.get('tipConfig'); | ||
if (!tipConfig) { | ||
tipConfig = [ {name: 'Value', percentage: false} ]; | ||
} | ||
var legend; | ||
@@ -184,3 +195,10 @@ | ||
.html(function (d) { | ||
return "<strong>Value:</strong> <span style='color:red'>" + (helper.toFixed2(d.value)) + "</span>"; | ||
var result = ""; | ||
for(var i = 0; i < tipConfig.length; i++) | ||
if (tipConfig[i].percentage) { | ||
result += "<strong>" + tipConfig[i].name + ":</strong> <span style='color:red'>" + (helper.toFixed2(d.value*100/that.total)) + "%</span><br/>"; | ||
} else { | ||
result += "<strong>" + tipConfig[i].name + ":</strong> <span style='color:red'>" + (helper.toFixed2(d.value)) + "</span><br/>"; | ||
} | ||
return result; | ||
}); | ||
@@ -187,0 +205,0 @@ |
{ | ||
"name": "d-grouped-barchart", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "Derby grouped bar chart component using d3 and d3-tip.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
142657
749