Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wpoely86/D3.js-Diverging-Stacked-Bar-Chart
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Interana/D3.js-Diverging-Stacked-Bar-Chart
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Dec 19, 2015

  1. Relabel for sort/split

    mkedwards committed Dec 19, 2015
    Copy the full SHA
    f0aad71 View commit details
Showing with 8 additions and 9 deletions.
  1. +8 −9 index.html
17 changes: 8 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>Diverging Stacked Bar Chart with D3.js</title>
<title>Effect on sort backlog</title>
<style>

body {
@@ -84,18 +84,17 @@ <h1>Diverging Stacked Bar Chart</h1>
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

color.domain(["Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree"]);
color.domain(["Delete unsorted folder", "Sort success", "Sort failure", "Split", "Append to sorted folder"]);

d3.csv("raw_data.csv", function(error, data) {

data.forEach(function(d) {
// calc percentages
d["Strongly disagree"] = +d[1]*100/d.N;
d["Disagree"] = +d[2]*100/d.N;
d["Neither agree nor disagree"] = +d[3]*100/d.N;
d["Agree"] = +d[4]*100/d.N;
d["Strongly agree"] = +d[5]*100/d.N;
var x0 = -1*(d["Neither agree nor disagree"]/2+d["Disagree"]+d["Strongly disagree"]);
d["Delete unsorted folder"] = +d[1];
d["Sort success"] = +d[2];
d["Sort failure"] = +d[3];
d["Split"] = +d[4];
d["Append to sorted folder"] = +d[5];
var x0 = -1*(d["Sort failure"]/2+d["Sort success"]+d["Delete unsorted folder"]);
var idx = 0;
d.boxes = color.domain().map(function(name) { return {name: name, x0: x0, x1: x0 += +d[name], N: +d.N, n: +d[idx += 1]}; });
});