简体   繁体   English

Highcharts传奇字体大小

[英]Highcharts legend font sizes

I'm using Highcharts for my web page and I can't seem to figure out how to correctly change the font size of the title and key at the bottom. 我在我的网页上使用Highcharts,我似乎无法弄清楚如何正确更改底部标题和键的字体大小。 I'm using the basic column with green background: http://www.highcharts.com/demo/column-basic/dark-green 我正在使用绿色背景的基本栏目: http//www.highcharts.com/demo/column-basic/dark-green

Currently this is my code: 目前这是我的代码:

Function: 
$(function () {
    $('#content').highcharts({
        chart: {
            type: 'column'
        },
        legend: {
            itemStyle: {
                color: 'white',
                fontWeight: 'bold',
                fontSize: '20px'
            }
        },
        title: {
            text: 'Title',
            style:{
                    color: 'white',
                    fontSize: '25px'
                }       
        },
        subtitle: {
            text: 'Subtitle'
        },
         xAxis: {
            categories: [
                ' '
            ]
        },
        yAxis: {
            min: 0,
            title: {                    
                text: 'MMBTUs x 10,0000',
                style:{
                    color: 'white',
                    fontSize: '25px'
                }
            },
            labels: {
                style: {
                    color: 'white',
                    fontSize:'25px'
                }
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: [{
            name: '2009',
            data: [4900000]

        }, {
            name: '2010',
            data: [4900000]

        }, {
            name: '2011',
            data: [5500000]

        }, {
            name: '2012',
            data: [5200000]

        }]
    });
});

Html call: Html电话:

<div id="content" style="min-width: 300px; height: 1000px; margin: 2px; margin-bottom: 3px"></div>

and as stated I'm using the Highcharts green theme provided by the website when you click view visual theme. 如上所述,当您点击查看视觉主题时,我正在使用网站提供的Highcharts绿色主题。

Now my problem is when I change: 现在我的问题是我改变时:

legend: {
        itemStyle: {
            color: 'white',
            fontWeight: 'bold',
            fontSize: '20px'
        }

depending on how big my font size is the 4 values (2009, 2010, 2011, 2012) are either not visable or the move out of the box below the chart. 取决于我的字体大小有多大,4个值(2009年,2010年,2011年,2012年)要么不可见,要么在图表下方移出框。 The box itself doesn't resize (which it does in jfiddle which doesn't include the theme). 框本身不会调整大小(它在jfiddle中执行,不包括主题)。 The same thing happens with: 同样的事情发生在:

title: {
        text: 'Title',
        style:{
                color: 'white',
                fontSize: '25px'
            }       
    },

the color changes based on my value but the font size doesn't. 颜色根据我的值而改变,但字体大小没有。 Any help would be appreciated. 任何帮助,将不胜感激。

That theme uses font instead of fontSize. 该主题使用font而不是fontSize。 So, it's legend is defined as: 因此,它的传奇定义为:

 legend: {
              itemStyle: {
                 font: '9pt Trebuchet MS, Verdana, sans-serif',
                 color: '#A0A0A0'
              },
              itemHoverStyle: {
                 color: '#FFF'
              },
              itemHiddenStyle: {
                 color: '#444'
              }

        },

If you define your's with both font and fontSize, it'll work (seems like a bug to me, but maybe it's a feature): 如果你用font和fontSize定义你的,它会起作用(对我来说似乎是一个bug,但也许它是一个特性):

 legend: {
              itemStyle: {
                 fontSize:'20px',
                 font: '20pt Trebuchet MS, Verdana, sans-serif',
                 color: '#A0A0A0'
              },
              itemHoverStyle: {
                 color: '#FFF'
              },
              itemHiddenStyle: {
                 color: '#444'
              }

        },

I assume the title has the same thing going on. 我认为标题有同样的事情发生。

http://jsfiddle.net/kHzr9/ http://jsfiddle.net/kHzr9/

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

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