调整datalabel列highcharts顶部 [英] aligning datalabel to top of column highcharts

查看:475
本文介绍了调整datalabel列highcharts顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的datalabel柱内顶端如果列正在上升或底部,如果列正在下降为c的这个$ C $左对齐,中间现在。

I'm trying to get my datalabel inside the column to the top if the column is going up or to the bottom if the column is going down right now with this code its aligned to the left in the middle.

plotOptions: {
        series: {
        stacking: 'normal',
            dataLabels: {
                align: 'top',
                enabled: true,
                formatter: function() {
                    return this.y.toFixed(2) +' %';
                }
            }
        }
    },

我将如何做到这一点?此外,如果通过highcharts显示的列不一样宽的文字,我怎么会检查这一点,把文字放在列呢?

How would I do this? Also if the column displayed by highcharts isn't as wide as the text, how would I check for that and put the text over the column instead?

推荐答案

您可以在移动datalabels到底负列,通过翻译功能。

You can "move" datalabels to bottom in negative columns, by translate function.

http://jsfiddle.net/wMLg6/33/

 var datalabel;

        $.each(chart.series[0].data,function(j,data){
            if(data.y < 0)
            {
                datalabel = data.dataLabel;
                datalabel.translate(datalabel.x,data.plotY-20);
            }
        });

这篇关于调整datalabel列highcharts顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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