Highcharts x轴标签文字环绕设置标签步骤丢失 [英] Highcharts x axis label text wrapping lost on setting label step

查看:86
本文介绍了Highcharts x轴标签文字环绕设置标签步骤丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Highcharts标签在X轴上环绕时出现问题。如下面链接所示,设置
标签step属性时丢失了。



正确: http://jsfiddle.net/Bimal/45Lp3/



不正确: http://jsfiddle.net/ahwmv/


$ b $

  $(function(){
$('#container')。highcharts({

图表:{
},

xAxis:{
类别:['Apple Orange:PineApple芒果葡萄(销售额百分比)','Feb','Mar','Apr ','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
标签:{
step:1
}
},

系列:[{
数据:[29.9,71.5,106.4,129.2,144.0,176.0,135.6,148.5,216.4,194.1,95.6 ,54.4]
}]
});

});

当xAxis.labels.step设置为默认的空值时,文本换行完成。
请提供一种维护包装的方法,当标签步骤被赋予一个数值时。

谢谢

解决方案

这有点破解,但可以用< br /> 来替换名称中的每个空格。使用格式化程序

  labels:{
step: 1,
formatter:function(){
return this.value.replace(/ / g,'< br />');






$ b

这不完全是你想要的,因为它没有根据刻度之间的可用空间拆分名称,但也许可以改进格式化程序以更好地满足您的需要(例如按给定的 n 字符拆分,而不是按空格拆分)。



请参阅此处


I have a problem with the Highcharts label wrapping on the X axis .It is lost on setting the label step property as shown in the links below

Correct: http://jsfiddle.net/Bimal/45Lp3/

Incorrect: http://jsfiddle.net/ahwmv/

 $(function () {
$('#container').highcharts({

    chart: {
    },

    xAxis: {
        categories: ['Apple Orange: PineApple Mango Grapes (% of Sales)', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        labels: {
            step: 1
        }
    },

    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]        
    }]
});

});

When xAxis.labels.step is set to its default null value ,the text wrapping is done . Please suggest a way to maintain the wrapping when the labels step is given a numeric value.

Thanks

解决方案

It's a bit of a hack, but you could replace each space in the name with <br /> by using the formatter:

labels: {
    step: 1,
    formatter: function () {
        return this.value.replace(/ /g, '<br />');
    }
}

It's not exactly what you want as it doesn't split the name according to the space available between ticks, but maybe you can improve the formatter to better suit your needs (splitting by a given n characters for example instead of by space).

See it running here.

这篇关于Highcharts x轴标签文字环绕设置标签步骤丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆