繁体   English   中英

高图设置yAxis标签宽度

[英]Highcharts set yAxis labels width

是否可以设置标签宽度或其他选项,因此更改标签值时图形将不会移动/调整。

yAxis: {
        title: { text: '' },
        useHTML: true,
        labels: {
            formatter: function() {
                return '<div class="yAxisCustomLabel">' + moneySign + this.axis.defaultLabelFormatter.call({
                    axis: this.axis,
                    value: this.value
                }) + '</div>';
            }
        }
    }

我试图制作一个自定义类并添加样式,但是没有成功,也许是因为它是svg的一部分。

在此处输入图片说明

您可以设置marginLeft ,这可以给yAxis足够的空间。

这是maginLeft的示例:200;

 Highcharts.chart('container', { chart: { type: 'line', borderWidth: 1, plotBorderWidth: 1, marginLeft: 200 }, xAxis: { categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] }, yAxis: { labels: { format: 'this is a very long label' } }, tooltip: { formatter: function () { return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y; } }, plotOptions: { }, 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] }] }); 
 <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 400px"></div> 

暂无
暂无

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

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