我需要根据数据最小值缩放d3折线图,以便Y轴不应从零开始。
var svg = d3.select("#chart"),
margin = {top: 20, right: 20, bottom: 110, left: 40},
margin2 = {top: 430, right: 20, bottom: 30, left: 40},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom,
height2 = +svg.attr("height") - margin2.top - margin2.bottom;
var parseDate = d3.timeParse("%Y-%m-%d %H:%M:%S");
var x = d3.scaleTime().range([0, width]),
x2 = d3.scaleTime().range([0, width]),
y = d3.scaleLinear().range([height, 0]),
y2 = d3.scaleLinear().range([height2, 0]);
var xAxis = d3.axisBottom(x),
xAxis2 = d3.axisBottom(x2),
yAxis = d3.axisLeft(y);
var line = d3.line()
.x(function (d) { return x(d.created_at); })
.y(function (d) { return y(d.temp); });
var line2 = d3.line()
.x(function (d) { return x2(d.created_at); })
.y(function (d) { return y2(d.temp); });
x.domain(d3.extent(data, function(d) { return d.created_at; }));
y.domain([0, d3.max(data, function (d) { return d.temp; })]);
x2.domain(x.domain());
y2.domain(y.domain());
试图使用floatingScale,但似乎不起作用。