javascript - 在 highchart 中,Y 轴绘图线标签被 chop

标签 javascript charts highcharts bar-chart

我想创建添加了自定义水平线以显示平均基准的条形图。这些行上还添加了标签以显示基准标题。我将线标签切断,如下图所示。 Barchart

此外,如果绘图线值超出绘图范围,绘图线将被隐藏。如何在 Highcharts 中处理这种情况?以下是我正在使用的代码。

$(function () { 
    $('#chartContainer').highcharts({
    	credits: {
    	    enabled: false
    	},
    	colors: ['#3C791D','#BEBEBE','#7F7F7F'],
        chart: {
            type: 'column'
        }, 
        title: {
            text: ''
        },
        xAxis: {
            categories: ['Great', 'Neutral', 'Bad']
        },
        yAxis: {
            title: {
                text: ''
            },
            plotLines:[{
                value:80,
                color: '#000000',
                width:2,
                zIndex:4,
                label:{
                	text:'XYZ Average: 80%',
                	align: 'right'
                }
            },{
                value:60,
                color: '#000000',
                width:2,
                zIndex:4,
                label:{
                	text:'PQR Average: 60%',
                	align: 'right'
                }
            }]
        },
        legend: {
        	enabled : false
        },
        plotOptions: {
            column: {
                dataLabels: {
                    enabled: true,
                    formatter:function() {
                    	return this.y + '%';
                    }
                },
                colorByPoint: true,
                enableMouseTracking: false
            }
        },
        series: [{
        	type: 'column',
        	name: "s",
            data: [70, 10, 40]
        }]
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<html>
<body>
<div id="chartContainer"></div>
</body>
</html>

最佳答案

设置图表的高度以及Y轴的最大值

chart: {
  height: 600
},
yAxis: {
  min: 0,
  max: 100
}

关于javascript - 在 highchart 中,Y 轴绘图线标签被 chop ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35933647/

相关文章:

javascript - 如何从另一个系列或数据中获取值

javascript - ammo.js 在谷歌浏览器中的性能

javascript - 如果元素在容器外部,是否可以相对于容器定位具有绝对定位的元素?

javascript - Map() 返回重复组件

javascript - D3.js 中的堆叠区域

scala - 修改从 Scala 中的方法返回的值(Highcharts lib)

javascript - 具有父节点和公共(public)节点的 d3 和 Highcharts 图

javascript - 如何使用 ClassName 将条目添加到 DIV

javascript - 3D 图形库中的树状图

sql - 钻取 SSRS 中的报告