d3 mouseover tip.show теперь работает, когда работает (a, b, c) - PullRequest
0 голосов
/ 18 марта 2019

У меня есть всплывающая подсказка d3

var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
  return '<strong>Value:</strong> <span class="d3-tip-value>' + d.value + '</span>';
});
svg.call(tip);

Итак, у меня есть больше кода в функции (a, b, b) при наведении курсора на точку, а также метод tip.show, который не работает таким образом:

svg.selectAll(".dot")
  .data(dataset)
  .enter().append("circle")
  .attr("class", "dot")
  .attr("cx", function(d, i) { return xScale(new Date(d.y.date)) })
  .attr("cy", function(d) { return yScale(d.y.value) })
  .attr("r", 4)
  .on("mouseover", function(a, b, c) {
      tip.show; // NOT WORKING
      ......

, но tip.show работает следующим образом:

svg.selectAll(".dot")
  .data(dataset)
  .enter().append("circle")
  .attr("class", "dot")
  .attr("cx", function(d, i) { return xScale(new Date(d.y.date)) })
  .attr("cy", function(d) { return yScale(d.y.value) })
  .attr("r", 4)
  .on("mouseover", tip.show) // WORKING
...