Skip to content

Instantly share code, notes, and snippets.

@Atomy9
Created October 24, 2017 13:56
Show Gist options
  • Save Atomy9/42db5b136a2d5101489b043d97878601 to your computer and use it in GitHub Desktop.
Save Atomy9/42db5b136a2d5101489b043d97878601 to your computer and use it in GitHub Desktop.
Histogramme des pépites
license: mit
Chaîne Pépite or not Auteur Abonnés Réflexion Amusement Need more Level up c bo OMG Mind blown So deep Beau boulot Satisfait Malin Frustration Malhonnêteté Irritation Choqué Déçu Malaise Total Note
Horror Humanum Est oui Antony 180 000 2 1 3 2 3 2 2 2 1 0 0 0 0 0 0 0 18 19
Horror Humanum Est oui Florian 180 000 2 1 2 3 3 2 2 2 1 0 0 0 0 0 0 0 18
Horror Humanum Est oui Louis 180 000 2 1 2 2 3 1 2 3 2 1 0 0 0 0 0 0 19
Horror Humanum Est oui Nicolas 180 000 2 1 3 3 3 1 2 3 1 1 0 0 0 0 0 0 20
Ibra TV non Antony 2 300 000 0 1 0 0 0 0 0 0 0 2 0 -1 -3 -1 -1 -3 -6 -12
Ibra TV non Florian 2 300 000 0 1 0 0 0 0 0 0 0 0 0 -3 -2 -3 -1 -3 -11
Ibra TV non Louis 2 300 000 0 1 1 0 0 0 0 0 0 0 -2 -3 -3 -2 -2 -3 -13
Ibra TV non Nicolas 2 300 000 0 0 0 0 0 0 0 0 0 0 -2 -3 -3 -3 -3 -3 -17
Tu mourras moins bête oui Antony 160 000 2 3 3 3 2 2 1 3 0 2 0 0 0 0 0 0 21 19
Tu mourras moins bête oui Florian 160 000 2 3 3 3 2 2 1 2 1 2 0 0 0 0 0 0 21
Tu mourras moins bête oui Louis 160 000 2 1 2 2 2 1 1 2 1 2 0 0 0 0 0 0 16
Tu mourras moins bête oui Nicolas 160 000 2 1 1 2 2 2 1 2 2 1 0 0 0 0 0 0 16
Cocovoit oui Antony 21 500 0 3 3 0 1 1 0 3 3 3 0 0 0 0 0 -1 16 17
Cocovoit oui Florian 21 500 1 2 2 1 1 1 1 2 3 3 0 0 0 0 0 0 17
Cocovoit oui Louis 21 500 1 2 2 1 2 1 1 2 2 1 0 0 0 0 0 0 15
Cocovoit oui Nicolas 21 500 3 1 2 2 2 2 2 2 2 2 0 0 0 0 0 0 20
Squeezie non Antony 9 000 000 0 3 1 0 1 0 0 1 1 1 0 0 -2 -1 -1 -2 2 7
Squeezie non Florian 9 000 000 1 3 1 0 1 0 0 2 1 1 0 -1 -1 0 0 0 8
Squeezie non Louis 9 000 000 1 2 2 1 1 1 0 1 1 1 0 0 0 0 0 0 11
Squeezie non Nicolas 9 000 000 0 3 1 1 1 0 0 6
Jojol non Antony 1 157 000 1 0 0 1 0 0 0 1 1 0 -2 -1 -2 0 -1 0 -2 -8
Jojol non Florian 1 157 000 0 0 0 0 0 0 0 0 0 0 -2 -1 -2 0 -1 0 -6
Jojol non Louis 1 157 000 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1 -2 -3 -9
Jojol non Nicolas 1 157 000 1 0 0 0 0 0 0 0 0 -3 -3 -3 -3 -1 -3 -15
Startup Heroes oui Antony 66 000 2 3 3 1 3 0 0 3 3 2 0 0 0 0 0 0 20 19
Startup Heroes oui Florian 66 000 1 3 3 1 3 1 1 3 3 3 0 0 0 0 0 0 22
Startup Heroes oui Louis 66 000 2 1 2 1 2 2 1 2 1 1 0 0 0 0 0 0 15
Startup Heroes oui Nicolas 66 000 2 1 2 1 2 2 2 2 2 1 0 0 0 0 0 0 17
Swan the voice non Antony 1 800 000 0 0 0 0 0 0 0 0 0 0 -1 -3 -3 -3 -3 -3 -16 -10
Swan the voice non Florian 1 800 000 0 0 0 0 0 0 0 0 0 0 -1 -3 -3 -3 -3 -3 -16
Swan the voice non Louis 1 800 000 0 0 0 0 0 0 0 0 0 0 -1 0 -1 -1 -3 -3 -9
Swan the voice non Nicolas 1 800 000 0
Data Gueule oui Antony 380 000 3 0 3 3 3 3 3 3 3 1 0 0 0 0 0 0 25 24
Data Gueule oui Florian 380 000 3 1 3 3 3 3 3 3 3 2 0 0 0 0 0 0 27
Data Gueule oui Louis 380 000 3 1 2 2 2 2 2 3 2 2 0 0 0 0 0 0 21
Data Gueule oui Nicolas 380 000 3 1 3 2 2 2 3 3 2 2 0 0 0 0 0 0 23
EnjoyPhoenix non Antony 3 000 000 0 0 0 0 0 0 0 0 0 0 -1 -1 -3 -1 -1 -2 -9 -6
EnjoyPhoenix non Florian 3 000 000 0 0 0 0 1 0 0 1 0 0 -1 -2 -1 0 -1 -3
EnjoyPhoenix non Louis 3 000 000 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 -2 -3 -7
EnjoyPhoenix non Nicolas 3 000 000 1 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -3 -5
<!DOCTYPE html>
<style>
.axis .domain {
display: none;
}
</style>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
margin = {top: 20, right: 20, bottom: 30, left: 40},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom,
g = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var x0 = d3.scaleBand()
.rangeRound([0, width])
.paddingInner(0.1);
var x1 = d3.scaleBand()
.padding(0.05);
var y = d3.scaleLinear()
.rangeRound([height, 0]);
var z = d3.scaleOrdinal()
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]);
d3.csv("datanuggetfull.csv", function(d, i, columns) {
d[columns[1]] = d[columns[1]] == "oui" ? 1 : 0;
d[columns[3]] = parseInt(d[columns[3]].replace(" ",""));
for (var i = 4, n = columns.length; i < n; ++i) d[columns[i]]= +d[columns[i]]
return d;
}, function(error, data_orig) {
if (error) throw error;
data = []
var keys = d3.nest().key(function(d) { return d["Chaîne"]; }).entries(data_orig)
console.log(data_orig);
console.log(keys);
for (k in keys) {
console.log(keys[k].key)
data[k]["Chaîne"] = keys[k].key
}
return;
x0.domain(data.map(function(d) { return d["Chaîne"]; }));
x1.domain(keys).rangeRound([0, x0.bandwidth()]);
return
y.domain([0, d3.max(data, function(d) { return d3.max(keys, function(key) { return d[key]; }); })]).nice();
g.append("g")
.selectAll("g")
.data(data)
.enter().append("g")
.attr("transform", function(d) { return "translate(" + x0(d.State) + ",0)"; })
.selectAll("rect")
.data(function(d) { return keys.map(function(key) { return {key: key, value: d[key]}; }); })
.enter().append("rect")
.attr("x", function(d) { return x1(d.key); })
.attr("y", function(d) { return y(d.value); })
.attr("width", x1.bandwidth())
.attr("height", function(d) { return height - y(d.value); })
.attr("fill", function(d) { return z(d.key); });
g.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x0));
g.append("g")
.attr("class", "axis")
.call(d3.axisLeft(y).ticks(null, "s"))
.append("text")
.attr("x", 2)
.attr("y", y(y.ticks().pop()) + 0.5)
.attr("dy", "0.32em")
.attr("fill", "#000")
.attr("font-weight", "bold")
.attr("text-anchor", "start")
.text("Note");
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment