This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// percentage = value / total * 100 | |
// store total in variable | |
var total = d3.sum(data, function(d) { return d.values; }); | |
// set upper domain of y-axis not to 100% but to the percentage of the greatest value in your data | |
y.domain([0, d3.max(data, function(d) { return Math.round((d.values / total) * 100); })]); | |
// percentage in bar chart | |
var bars = d3.selectAll('.bar') | |
.data(data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on function call autocreate data agnostic filters | |
function createFilter(name, data) { | |
var items = []; | |
for (i in data) { | |
items.push(data[i][name]); | |
} | |
var list = items.filter(uniqueValues); | |
list.sort(); | |
$.each(list, function(i, item) { |
NewerOlder