Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用zoomtype使用highcharts更新fontsize_Javascript_Jquery_Highcharts - Fatal编程技术网

Javascript 使用zoomtype使用highcharts更新fontsize

Javascript 使用zoomtype使用highcharts更新fontsize,javascript,jquery,highcharts,Javascript,Jquery,Highcharts,我在Highcharts中有一个列图表,有很多列,所以列非常小。 那很好,但我想做缩放。 所以我使用了zoomtype:'x',效果很好 问题是我想在选择xAxis时使其字体变大。 我试着这样做: chart: { type: 'column', zoomType: 'x', events: { redraw: function(event) { if(

我在Highcharts中有一个列图表,有很多列,所以列非常小。 那很好,但我想做缩放。 所以我使用了zoomtype:'x',效果很好

问题是我想在选择xAxis时使其字体变大。 我试着这样做:

chart: {
            type: 'column',
            zoomType: 'x',
            events: {
                redraw: function(event) {
                    if(this.xAxis[0].tickPositions.length>80){
                        this.xAxis[0].options.labels.style.fontSize = 1;
                    }else{
                        this.xAxis[0].options.labels.style.fontSize = 20;
                        console.log(this.xAxis[0].options.labels.style.fontSize);                  
                    }

                }

            }
        }
检查控制台时,此.xAxis[0].options.labels.style.fontSize的值将更新为20。 此代码仅在我按下重置缩放按钮时有效。 因此,我的问题是,当事件被触发时,如何更新图表,使其产生与使用重置缩放按钮相同的效果

或者,在进行缩放和重置缩放时,如何更改字体?

您可以捕捉事件,然后使用新的捆样式

events:{
            afterSetExtremes:function(){
                this.update({
                    labels:{
                        style:{
                            fontSize:20
                        } 
                    }
                });
            }
 }

示例:

它工作得非常好!!我浪费了很多时间尝试其他不起作用的东西。非常感谢你。