【发布时间】:2014-10-01 23:22:34
【问题描述】:
我有一个使用 D3 可视化数据的 Cordova/Ionic 应用程序。
我使用 D3 缩放功能来左右平移数据
var zoomListener = d3.behavior.zoom()
.scaleExtent([1, 1])
.x(xScale)
.on("zoom", function() {
...
...
});
var svg = d3.select("#animation-container")
.append("svg")
.attr("id", "ecogram")
.attr("width", options.width)
.attr("height", options.height)
.call(zoomListener)
.append("g")
.attr("transform", "translate(" + options.margin.left + "," + options.margin.top + ")");
我可以在 SVG 平移之外的组件的单击和等待事件侦听器上添加离子弹出框功能,例如:
<h1 on-hold="openPopover($event)">Open Popover</h1>
但是当我像下面的代码一样使用 D3 将它们添加到 SVG 时,事件不会触发。
xAxisGroup = svg.append("g")
.attr("class", "x axis");
xAxisGroup
.append('svg:use')
.attr("x", options.startPinX)
.attr("y", options.startPinY)
.attr("width", options.iconWidth)
.attr("height", options.iconHeight * 1.3)
.attr("class", "ticker start-pin")
.attr("on-hold", "openPopover($event)")
.attr("xlink:href", "img/icons.svg#icon-pin");
是否可以同时附加 D3 缩放事件处理程序和单击/按住事件处理程序?
【问题讨论】:
标签: javascript svg d3.js ionic-framework