简体   繁体   English

Highcharts - 传奇物品填充

[英]Highcharts - Legend item padding

There seem to be a problem with the padding of text for label items in Highcharts. Highcharts 中标签项的文本填充似乎存在问题。 I get very different results in Firefox compared to Chrome: http://jsfiddle.net/moppa/cMXyG/18/与 Chrome 相比,我在 Firefox 中得到了非常不同的结果: http : //jsfiddle.net/moppa/cMXyG/18/

差异示例

If I inspect the elements in the browser the tspan tag has a height of 16px in Chrome, but 20px.如果我检查浏览器中的元素, tspan标签在 Chrome 中的高度为 16 像素,但为 20 像素。 In FF it looks like some pixels has been added as padding, since the text does not fill up the whole tag.在 FF 中,它看起来像是添加了一些像素作为填充,因为文本没有填满整个标签。 I have experimented with line height and font-size settings of the legend.itemStyle , but no luck.我已经尝试过legend.itemStyle行高和字体大小设置,但没有运气。

Does anyone have any ideas?有没有人有任何想法? Firefox 25.0.1 and Chrome 31.0.1650.57m Firefox 25.0.1 和 Chrome 31.0.1650.57m

Attaching code to be compliant with the JSFiddle restriction:附加代码以符合 JSFiddle 限制:

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    legend: {
        layout: 'vertical',
        itemMarginTop: 0,
        itemMarginBottom: 0,
        align: 'right',
        verticalAlign: 'middle',
        padding:0
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
    {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
    {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
    {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
    {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]},
    {
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}]

});

Try with the itemMarginBottom properties like this:尝试使用itemMarginBottom属性,如下所示:

legend: {
    layout: 'vertical',
    itemMarginBottom:7,
    align: 'right',
    verticalAlign: 'top',
    itemStyle: {
        font: '9pt Raleway,Helvetica,sans-serif',
        color: '#A0A0A0'
    },
    itemHoverStyle: {
        color: '#FFF'
    },
    itemHiddenStyle: {
        color: '#444'
    }
}

Could you check with master version?你能检查一下主版本吗? This one example: http://jsfiddle.net/cMXyG/19/ .这个例子: http : //jsfiddle.net/cMXyG/19/ .

For me it looks fine, see:对我来说它看起来不错,请参阅:

  • FF:外:

火狐

  • Chrome:铬:

铬

There is small difference (~1px) probably caused by different calculations for lineWidth.可能由 lineWidth 的不同计算引起的小差异(~1px)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM