我有一个图例,我想把它的文字加粗。但是,我只希望激活的文本为粗体,如下例所示,我有 3 个圆圈,其中一个填充为黑色。该文本当前处于事件状态。
但是,我怎样才能使文本加粗,这样我就可以去掉圆圈,只使用文本来突出显示事件的标签?
我尝试从 nv-legend
中删除“circle”节点,它删除了 circle 节点,但在粗体文本中效果不佳:
var intervalControls = graph.select('.nv-wrap g')
.append('g')
.attr('class', 'nv-intervalWrap');
var controls = nv.models.legend()
.height(30)
.color(['#444', '#444', '#444']);
intervalControls
.datum(controlsErrorData[interval])
.attr('transform', 'translate(-270,-50)')
.call(controls)
$('.nv-intervalWrap')
.find('g')
.find('.nv-series')
.find('.nv-legend-symbol')
.remove()
关于如何实现这一点有什么想法吗???
谢谢!
最佳答案
尝试将此添加到您的 CSS:
// Keep the in-active controls font normal
.nv-controlsWrap .disabled text {
font-weight: normal !important;
}
// Make the active link bold
.nv-controlsWrap .nv-series text {
font-weight: 600;
}
希望对您有所帮助。
关于javascript - 如何更改 nvd3 中图例文本的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27412364/