d3/examples/axis/axis-ggplot2.html

71 строка
1.2 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<script src="../../d3.js"></script>
<style>
body {
font: 10px sans-serif;
}
rect {
fill: #ddd;
}
.grid line {
stroke: #fff;
}
.grid line.minor {
stroke-width: .5px;
}
.grid text {
display: none;
}
.axis line {
stroke: #000;
}
path {
display: none;
}
</style>
<body>
<script>
var margin = {top: 10, right: 10, bottom: 20, left: 10},
width = 960 - margin.right - margin.left,
height = 80 - margin.top - margin.bottom;
var x = d3.scale.linear()
.domain([.05, .95])
.range([0, width]);
var y = d3.scale.linear()
.range([0, height]);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.right + margin.left)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("rect")
.attr("width", width)
.attr("height", height);
svg.append("g")
.attr("class", "x grid")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).tickSubdivide(1).tickSize(-height));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x));
</script>