我正在尝试重新绘制条形图,如果窗口重新调整大小,哪个工作正常但我还需要重绘轴,由于某种原因它不起作用,这是我的代码
$(window).resize(function change() {
var tempScale;
var newAxis;
//bar chart is drawn horizontally
if ($(window).width() < width) {
//create a new scale on window resize
tempScale = d3.scale.linear()
.domain([0, d3.max(arr)])
.range([0, $(window).width()]);
// intialize newAxis which is adjusted to tempScale
newAxis = d3.svg.axis().scale(tempScale);
}
else {
//set tempScale to default scale
tempScale = scale1;
}
//modify the bar chart according to new scale
canvas2.selectAll("rect")
.data(arr)
.attr("width", function (d) { return tempScale(d); })
.attr("height", 10)
//this call is not working
.call(newAxis);
});
我也得到错误&#34;无法阅读财产&#39;申请&#39;未定义&#34;。希望我提前提供足够的信息。