Created
April 2, 2022 08:49
-
-
Save sunmoonStern/3eb81b30f4efde0b2a06a1d102119f04 to your computer and use it in GitHub Desktop.
funin-data
This file contains 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
<div id="title">35歳以上40歳未満の女性に対して凍結胚を用いた治療成績可視化テスト</div> | |
<div id="wrapper"> | |
<canvas id="chart_demo"></canvas> | |
<canvas id="chart"></canvas> | |
</div> |
This file contains 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
var chart = new Chart('chart_demo', { | |
type: 'horizontalBar', | |
data: { | |
labels: ['A', 'B', 'C'], | |
datasets: [ | |
{ | |
data: [10, 20, 30] | |
} | |
] | |
} | |
}); | |
function makeChart(players) { | |
// players is an array of objects where each object is something like: | |
// { | |
// "Name": "Steffi Graf", | |
// "Weeks": "377", | |
// "Gender": "Female" | |
// } | |
var playerLabels = players.map(function(d) { | |
return d.name; | |
}); | |
var weeksData = players.map(function(d) { | |
return +d.preg_count/d.et_count * 100; | |
}); | |
var chart = new Chart('chart', { | |
type: "horizontalBar", | |
options: { | |
maintainAspectRatio: false, | |
legend: { | |
display: false | |
} | |
}, | |
data: { | |
labels: playerLabels, | |
datasets: [ | |
{ | |
data: weeksData | |
} | |
] | |
} | |
}); | |
} | |
// Request data using D3 | |
d3 | |
.dsv("\t", "https://raw.githubusercontent.com/sunmoonStern/funin-open-data/main/hospital-data.tsv") | |
.then(makeChart); |
This file contains 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script> |
This file contains 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
#wrapper { | |
height: 1000px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment