plunkerでd3 その5
概要
plunkerでd3やってみた。
covid-19のjson読んで、table作ってみた。
写真
サンプルコード
d3.json("https://covid19-japan-web-api.now.sh/api/v1/positives", function(error, data) {
var keys = ["id", "announcement_date", "diagnosis_date",
"prefecture", "residence_prefecture", "age", "gender", "attribute", "prefecture_number", "travel_or_contact", "detail", "cluster", "src", "onset", "symptom", "death_or_discharge_date", "comment1", "outcome", "outcome_src", "comment2"];
var table = d3.select("body").append("table").attr("border", "1")
table.append("thead").append("tr").selectAll("th").data(keys).enter().append("th").text(function(d) {
return d;
});
for (var i = 0; i < data.length; i++)
{
var rows = [];
keys.map(function(c) {
rows.push(data[i][c])
});
table.append("tbody").append("tr").selectAll("td").data(rows).enter().append("td").text(function(d) {
return d;
});
}
});
成果物
d3.json("https://covid19-japan-web-api.now.sh/api/v1/positives", function(error, data) {
var keys = ["id", "announcement_date", "diagnosis_date",
"prefecture", "residence_prefecture", "age", "gender", "attribute", "prefecture_number", "travel_or_contact", "detail", "cluster", "src", "onset", "symptom", "death_or_discharge_date", "comment1", "outcome", "outcome_src", "comment2"];
var table = d3.select("body").append("table").attr("border", "1")
table.append("thead").append("tr").selectAll("th").data(keys).enter().append("th").text(function(d) {
return d;
});
for (var i = 0; i < data.length; i++)
{
var rows = [];
keys.map(function(c) {
rows.push(data[i][c])
});
table.append("tbody").append("tr").selectAll("td").data(rows).enter().append("td").text(function(d) {
return d;
});
}
});
以上。
Author And Source
この問題について(plunkerでd3 その5), 我々は、より多くの情報をここで見つけました https://qiita.com/ohisama@github/items/32fbbd895a7a9d96f617著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .