css - 如何禁用或覆盖网页中默认从 svg 继承的字体

标签 css svg highcharts fonts

当我需要更改 Highcharts 的数据标签时,我遇到了这个问题。

fiddle 链接:click here

Highcharts.chart('container', {
    colorAxis: {
        minColor: '#FFFFFF',
        maxColor: Highcharts.getOptions().colors[0]
    },
    series: [{
        type: 'treemap',
        layoutAlgorithm: 'squarified',
        data: [{
            name: 'DivisionA',
            value: 6,
            colorValue: 1
        }, {
            name: 'DivisionB',
            value: 6,
            colorValue: 2
        }, {
            name: 'DivisionC',
            value: 4,
            colorValue: 3
        }, {
            name: 'DivisionD',
            value: 3,
            colorValue: 4
        }, {
            name: 'DivisionE',
            value: 2,
            colorValue: 5
        }, {
            name: 'DivisionF',
            value: 2,
            colorValue: 6
        }, {
            name: 'DivisionG',
            value: 1,
            colorValue: 7
        }]
    }],
    title: {
        text: 'Highcharts Treemap'
    }
});
#container {
    min-width: 300px;
    max-width: 600px;
    margin: 0 auto;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/heatmap.js"></script>
<script src="https://code.highcharts.com/modules/treemap.js"></script>
<div id="container"></div>

如果使用 Chrome,请尝试检查数据标签,例如DivisionA,你会发现它的字体继承自svg。我尝试使用 .highcharts-container {.. }, 更改字体并应用 css,但它不起作用。

enter image description here

如有任何帮助,我们将不胜感激。

最佳答案

您需要改为定位 text 元素(tspan 的父元素)。所以你可以试试这个:

.highcharts-label text {
    font-family: ...;
}

关于css - 如何禁用或覆盖网页中默认从 svg 继承的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47886415/

相关文章:

javascript - Highcharts 在初始渲染后更新 pointRange、pointWidth

javascript - Chrome 调整大小事件和 getComputedStyle

html - 关于如何使用 css 向图像添加透明渐变的任何想法?

CSS Columns + overflow-y 滚动问题

javascript - d3js 强制布局在节点上隐藏/取消隐藏单击扩展后错放节点

javascript - jQuery - Div 不适合页面内容

html - 涉及 colspan 的表列大小调整

javascript - 附加文本不会显示 d3.js

html - SVG 半圆 : Why is it rotated?

javascript - 跨多个点跨越 Highcharts 中的类别