javascript - 取消缩放后图表外部的 D3 条形图
问题描述
我有一个使用 D3 的堆积条形图。x 轴是日期。还有对焦变焦。我根据可缩放堆叠条形图测试开始图表 我在取消缩放时遇到的问题。我无法让酒吧回到可视区域。我认为问题出在刷过的功能上。但是想不通。
function brushed() {
// update the main chart's x axis data range
x.domain(brush.empty() ? xOverview.domain() : brush.extent());
// redraw the bars on the main chart
layer.selectAll(".bar")
.attr("transform", function (d) { return "translate(" + x(d.x) + ",0)"; })
// redraw the x axis of the main chart
layer.select(".x.axis").call(xAxis);
}
我有一个关于 js fiddle 的完整示例:js fiddle example
缩放后如何使条形图回到可视区域?谢谢!
解决方案
推荐阅读
- php - 如何根据函数php的值自动生成number_format?
- javascript - 停止在移动设备上运行的 jQuery 图像缩放
- angular - Angular 7:更新全局变量的问题
- javascript - NodeJS 和 ReactJS:FormData 不工作
- ruby-on-rails - 添加到与另一个表共享 id 的表
- go - 仅在知道资源种类/类型时创建空的 Kubernetes 资源结构(在 golang 中)
- algorithm - 如何解决具有传递依赖关系/图的算法问题?
- matplotlib - 使用 matplotlib 更改子图的大小
- python-3.x - 使用第二个张量值循环张量维度 0 (NoneType)
- nsis - 如何使用 NSIS 对文件进行签名?