Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.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 在Highcharts条形图中居中数据标签_Javascript_Highcharts - Fatal编程技术网

Javascript 在Highcharts条形图中居中数据标签

Javascript 在Highcharts条形图中居中数据标签,javascript,highcharts,Javascript,Highcharts,我正在尝试在Highcharts中的条形图中居中放置标签。在我的例子中,你可以在这里看到一个倒瀑布图: 我试图在每个条内水平居中放置一个数据标签,这样,如果序列中的一个数据点的下限为1,y为3,那么该点将位于2。我尝试了high charts文档中建议的解决方法: 对于最新版本,它似乎不会通过更改格式化程序回调中的选项来影响渲染 非常感谢您的帮助。我快速查看了文档和您的示例,并在您的系列中使用dataLabel提出了暴力解决方案。显然,与中心对齐将在y轴上居中(例如,上面的3)。所以,我只是

我正在尝试在Highcharts中的条形图中居中放置标签。在我的例子中,你可以在这里看到一个倒瀑布图:

我试图在每个条内水平居中放置一个数据标签,这样,如果序列中的一个数据点的下限为1,y为3,那么该点将位于2。我尝试了high charts文档中建议的解决方法:

对于最新版本,它似乎不会通过更改格式化程序回调中的选项来影响渲染


非常感谢您的帮助。

我快速查看了文档和您的示例,并在您的系列中使用dataLabel提出了暴力解决方案。显然,与中心对齐将在y轴上居中(例如,上面的3)。所以,我只是使用datalabel上的x偏移量将其转换过来。这不是一个真正正确的解决方案,但可能会让您朝着正确的方向思考:

series: [{
    min: 0,
    max: versions.length + 1,
    data: [ { low: 1, y: 3 }, { low: 2, y: 4 }, { low: 3, y: 5 }, { low: 3, y: 5 } ],
    dataLabels: {
        enabled: true,
        color: '#FFFFFF',
        align: 'right',
        x: -130,
        y: 10,
        formatter: function() {
            return  versions[this.y - 1];
        },
        style: {
            fontSize: '13px',
            fontFamily: 'Verdana, sans-serif'
        }
    }                                    
}]

我知道这个很旧,但我只是需要这个,所以我是这样做的。我确定的解决方案是和alba lions示例的组合,使用stackLabels而不是dataLabels

yAxis:{
    stackLabels: {
        style: {
            color: 'white'       // Make the labels white
        },
        enabled: true,           // Enable stack labels
        verticalAlign: 'middle', // Position them vertically in the middle
        align: 'center',            // Align them to the left edge of the bar
        formatter: function() {
            return categories[this.x];
        }
    }
}
请参见尝试以下操作:

plotOptions: {
       series: {
       dataLabels: {                    
            enabled: true,
            color: '#000000',
            useHTML:true,
            style: {
                    fontSize: '13px',
                    fontFamily: 'Verdana, sans-serif'
                    },
            formatter:function(){
               return '<div align="center"><b><span>' + this.point.options.name + '</b><br />'+this.x+' '+this.y+'</span></div>';
 },
plotOptions:{
系列:{
数据标签:{
启用:对,
颜色:'#000000',
是的,
风格:{
fontSize:'13px',
fontFamily:“Verdana,无衬线”
},
格式化程序:函数(){
返回“+this.point.options.name+”
“+this.x+”+this.y+”; },
你的小提琴链接不起作用。你能添加一个更新的链接吗?