【问题标题】:nvd3 library, How to customize line chartnvd3库,如何自定义折线图
【发布时间】:2014-07-24 09:06:24
【问题描述】:

我正在使用 nvd3 在我的应用中绘制一些统计数据。 我想增加图表中线条的粗细。怎么可能?

谢谢

【问题讨论】:

    标签: css svg nvd3.js


    【解决方案1】:

    搜索负责当前行的stroke-width 的类。 然后插入一条更具体的规则,并在此处更改stroke-width 的值。

    this example from the nvd3 examples 中,stroke-width 由如下规则设置:

    .nvd3 .nv-groups path.nv-line
    

    所以我们创建一个匹配规则,稍微具体一点,例如:

    .nvd3 g.nv-groups path.nv-line
    

    并为stroke-width 附加一个新值:

    .nvd3 g.nv-groups path.nv-line {
      stroke-width: 5px;
    }
    

    【讨论】:

    • 但是……你是怎么找到的?我在代码或文档中看不到任何笔画宽度类...
    • @psv 使用浏览器的开发工具,在 HTML 中搜索路径元素,然后使用样式检查器。
    • 好的,你怎么知道当我们想要覆盖它时我们只需要在类中添加“g”?我还是不明白……
    • developer.mozilla.org/en-US/docs/Web/CSS/Specificityw3.org/TR/selectors/#specificity 经验法则是:使规则更具体,以便它针对更少的元素。
    • 非常有用。同样,我发现:.nvd3 g.nv-groups .nv-point { stroke-opacity: 1!important; stroke-width: 2px!important; fill-opacity: 1!important; }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-05
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 2013-04-17
    相关资源
    最近更新 更多