漂亮的悬停效果(D3图表)

时间:2016-03-19 01:06:12

标签: css d3.js

好吧,我试图在这张图表上模仿CSS效果:

http://bl.ocks.org/bobmonteverde/2070069

当您将鼠标悬停在某个点上时,会在该点周围创建一个更大的圆圈。

对于我的生活,我无法弄清楚我在自己的CSS中缺少的东西:)

我的小提琴:https://jsfiddle.net/y3LpjLph/3/

CSS:

/* Line Chart CSS */

.axis path,
.axis line {
  fill: none;
  stroke: #000;
  stroke-width: 3px;
  shape-rendering: crispEdges;
}

#pipeline-1,
#pipeline-2 {
  fill: none;
  stroke-width: 1.5px;
  stroke-linecap: round;

  transition: stroke-width 250ms linear;
  -moz-transition: stroke-width 250ms linear;
  -webkit-transition: stroke-width 250ms linear;

  transition-delay: 250ms
  -moz-transition-delay: 250ms;
  -webkit-transition-delay: 250ms;
}

.x.axis path {
/* Uncomment below if I want to remove x-axis line */
/*  display: none;*/
}

  stroke-opacity: 0;
  fill-opacity: 0;

#pipeline-chart-render {
  padding-left: -50px;
}

.area {
  fill: gray;
  opacity: 0.2;
}

.legend-items text {
  fill: steelblue;
}

.legend {
  fill: white;
  text-decoration-color: blue;
}
/* Simple tooltip CSS */


div.tooltip {
  position: absolute;
  background-color: rgba(255,255,255,1);
  padding: 10px;
  border: 1px solid #ddd;

  font-family: Arial;
  font-size: 13px;
  font-weight: bold;
  color: #7c795d;


  transition: opacity 500ms linear;
  -moz-transition: opacity 500ms linear;
  -webkit-transition: opacity 500ms linear;

  transition-delay: 500ms
  -moz-transition-delay: 500ms;
  -webkit-transition-delay: 500ms;

  -moz-box-shadow: 4px 4px 12px rgba(0,0,0,.5);
  -webkit-box-shadow: 4px 4px 12px rgba(0,0,0,.5);
  box-shadow: 4px 4px 12px rgba(0,0,0,.5);

  -moz-border-radius: 15px;
  border-radius: 15px;
}

.noPointers{
  pointer-events:none;
}

.pipelinePoint .circlePoint.active {
  fill: orangered;
  fill-opacity: 1;
  stroke-width: 25px;
  stroke-opacity: .5;
}

.pipelinePoint {
  stroke-opacity: 1;
  fill-opacity: 0.5;
}

.pipelinePoint .circlePoint {
  transition: stroke-width 250ms linear;
  -moz-transition: stroke-width 250ms linear;
  -webkit-transition: stroke-width 250ms linear;
}

/*.pipelinePoint .circlePoint.hover {
  fill: blue;
}*/

.circlePoint {
  fill-opacity: 0.5;
  transition: stroke-width 250ms linear;
  -moz-transition: stroke-width 250ms linear;
  -webkit-transition: stroke-width 250ms linear;
}

.point-paths path {
  /*
  fill: #eee;
  stroke: #aaa;
  */
  stroke-opacity: 0;
  fill-opacity: 0;
}

1 个答案:

答案 0 :(得分:1)

你已经填满了你的圈子,但他们没有笔触颜色。所以,你的css动画正在运行,没有什么可看的:

.pipelinePoint .circlePoint.active {
  fill: orangered;
  stroke: orangered;
  fill-opacity: 1;
  stroke-width: 25px;
  stroke-opacity: .5;
}

更新了fiddle