小编use*_*182的帖子

d3.js - mouseover事件在svg组上无法正常工作

我有一个图表,我需要一个参考线,鼠标光标位于此图中.此参考线将跟随图形内的鼠标移动.

但这似乎没有用.它仅适用于轴和轴的刻度线(.轴线).在调试时,我发现鼠标事件在SVG上应用时工作正常但在组上没有,为什么呢?

这是我的代码:

的test.html

<html>
<head>
<script src="jquery.js">
</script>
<script src="d3.v2.js">
</script>
<script src="retest.js">
</script>
<style type="text/css">
  .g_main {
    cursor:pointer;
  }

  .axis path, .axis line {
    stroke: #DBDBDB;
    /*shape-rendering: crispEdges;
    */
  }

  .y g:first-child text {
    display:none;
  }

  .y g:first-child line {
    stroke: #989898  ;
    stroke-width: 2.5px;
  }

  /*.x g:first-child line {
  stroke: black  ;
  stroke-width: 2.5px;
}
  */

  .y path {
    stroke: #989898  ;
    stroke-width: 2.5px;
  }

</style>
</head>
<body>  
<center>
  <button id="reload" onclick="loadViz();">
    load Graph
  </button>
  <div id="viz" …
Run Code Online (Sandbox Code Playgroud)

html javascript d3.js

24
推荐指数
1
解决办法
4万
查看次数

标签 统计

d3.js ×1

html ×1

javascript ×1