我以 10 分钟的间隔和 10 天的长度绘制股票价格图表。当然股市只在 9:30 到 4 点之间开市。如何只显示图表中上午 9:30 到 4 点之间的部分?例如谷歌金融图表https://www.google.com/finance?q=AAPL
var margin = {top: 10, right: 10, bottom: 10, left: 10};
var width = $('#'+stock.symbol+'_graph').width() - margin.left - margin.right;
var height = 100 - margin.top - margin.bottom;
var x = d3.time.scale().range([0, width]);
var y = d3.scale.linear().range([height, 0]);
var xAxis = d3.svg.axis().scale(x).orient("bottom");
var yAxis = d3.svg.axis().scale(y).orient("left");
var line = d3.svg.area()
.x(function(d) { return x(d.date); })
.y1(function(d) { return y(d.price); })
.y0(height);
var svg = d3.select('#'+stock.symbol+'_graph').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 + ")");
x.domain(d3.extent(stockHistory, function(d) { return d.date; }));
y.domain(d3.extent(stockHistory, function(d) { return d.price; }));
svg.append("path")
.datum(stockHistory)
.attr("class", "line")
.attr("d", line);