Is an NVD3 Line Plot with Markers Possible?

前端 未结 5 1292
野趣味
野趣味 2020-12-14 02:52

I\'m making an NVD3 line plot that will have significantly improved clarity if I can get markers to show for each data point instead of just the line itself. Unfortunately,

5条回答
  •  感情败类
    2020-12-14 02:56

    For current version of NVD3 (1.8.x), I use this D3-based solution (scripting only, no CSS file or style block required):

    nv.addGraph(function() {
      // ...
      return chart;
    },
    function() {
      // this function is called after the chart is added to document
      d3.selectAll('#myChart .nv-lineChart .nv-point').style("stroke-width",
        "7px").style("fill-opacity", ".95").style("stroke-opacity", ".95");
    }
    );
    

    The styles used are exactly the styles added by NVD3 by applying the "hover" class to each point (when hovered). Adjust them to your needs.

提交回复
热议问题