Skip to content

Instantly share code, notes, and snippets.

@n1n9-jp
Last active August 29, 2015 14:08
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 n1n9-jp/db71b18adc1500f459da to your computer and use it in GitHub Desktop.
Save n1n9-jp/db71b18adc1500f459da to your computer and use it in GitHub Desktop.
Comaparison of Nutrition Components in Bread Flour
name protein protein-error-range ash ash-error-range shop
シェリジー・トラディション・タイプ65 10.5 0 0.6 0 cuoca
ゆきちから 11 0 0.46 0 cuoca
ビリオン 12.8 0.5 0.41 0.03 cuoca
オーション 13 0.5 0.52 0.04 cuoca
スペルト 15 1 0.6 0.05 cuoca
そめいよしの 11.6 0 0.43 0 cuoca
ハナマンテン100 10.5 1.5 0.44 0.04 cuoca
南のめぐみ 10.1 0.3 0.45 0.03 cuoca
春の香りの青い空 11.3 0.5 0.49 0.3 cuoca
スローブレッドジャパネスク 10.6 1 0.45 0.05 cuoca
テリヤ特号 10.5 0.5 0.46 0 cuoca
レジャンデール 12.2 0 0.6 0 cuoca
テロワールピュール 9.5 0 0.53 0 cuoca
アンダンテ 11.7 0 0.35 0 cuoca
ウーヴリエ 11 0.5 0.57 0.05 cuoca
フランス 11.9 0 0.44 0 cuoca
1CW 12.3 0.3 0.39 0.03 cuoca
エペ 11 1 0.6 0.05 cuoca
カメリヤ 11.8 0 0.37 0 cuoca
グリストミル 13.5 1 0.95 0.1 cuoca
ゆめちから 12.5 0 0.48 0 cuoca
ムール・ド・ピエール 10.5 0.8 0.55 0.1 cuoca
スローブレッドクラシック 11.5 1 0.6 0.1 cuoca
スーパーファインハード 13.5 0 1.5 0 cuoca
ソレドォル 12 0.4 0.41 0.03 cuoca
トラディショナル 11.6 1 0.43 0 cuoca
スーパーキング 13.8 0 0.42 0 cuoca
ラ・トラディション・フランセーズ 10.5 2 0.55 0.1 cuoca
春よ恋 11 1 0.45 0.05 cuoca
リスドォル 10.7 0 0.45 0 cuoca
はるゆたか 11.5 1 0.46 0.05 cuoca
キタノカオリ 11.5 1 0.49 0.05 cuoca
レッジェーロ 11.3 0 0.42 0 cuoca
イーグル 12 0 0.35 0 cuoca
ゴールデンヨット 13.5 0 0.41 0 cuoca
コンチェルト 11.5 0 0.5 0 cuoca
ゆめかおり 12 1.5 0.95 0.2 cuoca
スーパーカメリヤ 11.5 0 0.33 0 cuoca
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
/* tooltip */
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 10px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
}
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
.d3-tip.n:after {
margin: -1px 0 0 0;
top: 100%;
left: 0;
}
</style>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3-tip/0.6.3/d3-tip.min.js"></script>
<script>
/* ------------------------------
initialize
------------------------------ */
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var xScale = d3.scale.linear()
.range([0, width]);
var yScale = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left");
/* ------------------------------
view port
------------------------------ */
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return "<span style='color:white'>" + d.name + "</span>";
});
svg.call(tip);
/* ------------------------------
load data & render
------------------------------ */
d3.tsv("bread-cuoca.tsv", function(error, data) {
data.forEach(function(d) {
d.protein = +d.protein;
d.ash = +d.ash;
});
// xScale.domain(d3.extent(data, function(d) { return d.protein; }));
// yScale.domain(d3.extent(data, function(d) { return d.ash; }));
xScale.domain([8, 16]);
yScale.domain([0.3, 1.6]);
/*
Axis
*/
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.append("text")
.attr("class", "label")
.attr("x", width)
.attr("y", -6)
.style("text-anchor", "end")
.text("たんぱく質(%)");
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("class", "label")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("灰分(%)")
/*
Circles
*/
svg.selectAll(".dot")
.data(data)
.enter().append("circle")
.attr("class", "dot")
.attr("r", 6)
.attr("cx", function(d) { return xScale(d.protein); })
.attr("cy", function(d) { return yScale(d.ash); })
.attr("title", function(d) { return d.name; })
.style("fill", function(d) {
if (d.shop =="tomizawa") {
return "red";
} else {
return "orange";
}
})
.style("stroke-width", "0px" )
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
/*
Text
*/
// svg.selectAll(".name")
// .data(data)
// .enter().append("text")
// .attr("class", "name")
// .attr("x", function(d) { return xScale(d.protein); })
// .attr("y", function(d) { return yScale(d.ash); })
// .attr("dx", ".7em")
// .attr("dy", ".4em")
// .style("fill", function(d) { return "black"; })
// .text(function(d) { return d.name; });
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment