Skip to content

Instantly share code, notes, and snippets.

@hyonschu
Created April 26, 2016 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyonschu/c10025d7cb17beb1bd237f9b6ddf01b8 to your computer and use it in GitHub Desktop.
Save hyonschu/c10025d7cb17beb1bd237f9b6ddf01b8 to your computer and use it in GitHub Desktop.
d3.csv('cancer_survival_rates.csv', function(csv) {
var dataset = []
for (var i=0; i<csv.length; i++) {
// console.log(data[i])
dataset.push( csv[i] )
}
// // layout variables
var pad = 50;
var hh = 1200;
var ww = 600;
var xmarks=[0,175,275,375,475]
var svg = d3.select("body")
.append("svg")
.attr("width", 1800)
.attr("height", 1200);
five=[]
ten=[]
fifteen=[]
for (i = 0; i<dataset.length; i++) {
five.push(dataset[i][5])
ten.push(dataset[i][10])
fifteen.push(dataset[i][15])
}
var master=d3.transpose([five,ten,fifteen])
// console.log(master)
var line = d3.svg.line()
.interpolate("basis")
.x(function(d, i) { return })
.y(master);
var group = svg
svg.selectAll(".line")
.data(dataset)
.enter().append("path")
.attr("class", "line")
.attr("d", line)
.attr({
'x': function(d) { console.log(d)
// console.log(d)
return _.keys(d)}
})
})
// console.log(dataset)
// data
group,5,10,15,20
Oral cavity,56.7,44.2,37.5,33
Oesophagus,14.2,7.9,7.7,5.4
Stomach,23.8,19.4,19,14.9
Colon,61.7,55.4,53.9,52.3
Rectum,62.6,55.2,51.8,49.2
Liver and intrahepatic bile duct,7.5,5.8,6.3,7.6
Pancreas,4,3,2.7,2.7
Larynx,68.8,56.7,45.8,37.8
Lung and bronchus,15,10.6,8.1,6.5
Melanomas,89,86.7,83.5,82.8
Breast,86.4,78.3,71.3,65
Cervix uteri,70.5,64.1,62.8,60
Corpus uteri and uterus,84.3,83.2,80.8,79.2
Ovary,55,49.3,49.9,49.6
Prostate,98.8,95.2,87.1,81.1
Testis,94.7,94,91.1,88.2
Urinary bladder,82.1,76.2,70.3,67.9
Kidney and renal pelvis,61.8,54.4,49.8,47.3
Brain and other nervous system,32,29.2,27.6,26.1
Thyroid,96,95.8,94,95.4
Hodgkin's disease,85.1,79.8,73.8,67.1
Non-Hodgkin lymphomas,57.8,46.3,38.3,34.3
Multiple myeloma,29.5,12.7,7,4.8
Leukaemias,42.5,32.4,29.7,26.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment