Html 更改 Highcharts 字体大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17707104/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:14:48  来源:igfitidea点击:

Changing Highcharts font size

javascripthtmlhighcharts

提问by Ryan Sayles

I'm looking at using HighCharts for a webpage, specifically:

我正在考虑将 HighCharts 用于网页,特别是:

http://www.highcharts.com/demo/column-basic/dark-green

http://www.highcharts.com/demo/column-basic/dark-green

However, the font sizes are too small. I've tried adding:

但是,字体大小太小。我试过添加:

legend: {
        itemStyle: {
            color: '#000000',
            fontWeight: 'bold',
            fontSize: '15px'
        }

to my js file that the site provided but this doesn't result in a font size change. Additionally I would also like to increase the size of the key (where it states Tokyo, New York, London, Berlin). This is my first time using Highcharts and I've been doing research for a couple hours now and I can't seem to find the answer. Any help would be much appreciated!

到我的网站提供的 js 文件,但这不会导致字体大小更改。此外,我还想增加密钥的大小(它表示东京、纽约、伦敦、柏林)。这是我第一次使用 Highcharts,我已经研究了几个小时,但似乎找不到答案。任何帮助将非常感激!

回答by Nishu Tayal

For legend font size, your code is working perfect. Here is working demo.

对于图例字体大小,您的代码运行良好。这是工作演示

and for X-axis and Y-axis,put the font size in (x-Axis/y-Axis)->labels->style object: Here is the sample :

对于 X 轴和 Y 轴,将字体大小放在 (x-Axis/y-Axis)->labels->style 对象中:这是示例:

 xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
            labels: {
                style: {
                    color: 'red',
                    fontSize:'15px'
                }
            }
        },

Demo :http://jsfiddle.net/4VznG/

演示:http: //jsfiddle.net/4VznG/

回答by Pretty Cool

I was having an issue setting fontSize of my x-Axis labels. Setting it using font in the labels worked for me:

我在设置 x 轴标签的 fontSize 时遇到问题。使用标签中的字体设置它对我有用:

xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        labels: {
            style: {
                color: 'red',
                font: '13px Arial, sans-serif'
            }
        }
    },

回答by Rajshee IFour

xAxis: {
        categories: ['Climate Change', 'Marketing', 'Development', 'Customer Support',
                'Information Technology', 'Administration'],
        tickmarkPlacement: 'on',
        lineWidth: 0,
        labels: {

            style: {
                fontSize: '14px',
                fontFamily: 'Verdana, sans-serif',

            }}
    },