3
我正试图实现this的效果。最接近我能找到的效果的一个工作示例是笛卡尔畸变效应,这似乎不适用于D3 V4。我真的不明白,所有线路需要改变或如何改变,以使这个例子与d3js版本4修改D3js V4的笛卡尔变换
(function chart3() {
console.clear()
var width = 960,
height = 180,
xSteps = d3.range(10, width, 16),
ySteps = d3.range(10, height, 16);
var xFisheye = d3.fisheye.scale(d3.scale.identity).domain([0, width]).focus(360),
yFisheye = d3.scale.linear().domain([0, height]);
var svg = d3.select("#chart3").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(-.5,-.5)");
svg.append("rect")
.attr("class", "background")
.attr("width", width)
.attr("height", height);
var xLine = svg.selectAll(".x")
.data(xSteps)
.enter().append("line")
.attr("class", "x")
.attr("y2", height);
redraw();
svg.on("mousemove", function() {
var mouse = d3.mouse(this);
// HACK (only for left-side)
xFisheye.focus(mouse[0] - 32); // HACK 1
yFisheye(mouse[1]);
if(mouse[0] > 26) // HACK 2
redraw();
});
function redraw() {
xLine.attr("x1", xFisheye).attr("x2", xFisheye);
}
})();
该插件的名称为*鱼眼*。据我所知,鱼眼不适用于D3 v4。纽约时报网页和小提琴都使用鱼眼。 NYT页面使用D3 v3.3,小提琴使用D3 v2。 –
是的,我知道。我想知道如果我有一个CSS解决方案来获得相同的效果 – devN