highchart堆叠列,在swift标签中显示极小的值

时间:2014-08-20 15:51:19

标签: javascript jquery charts highcharts stacked-chart

我目前正在使用[highchart js lib] [1]为我的项目创建堆积柱形图。

这是我的确切代码:

$(function () {
        $('#container').highcharts({
            yAxis: {
                min: 0,
                title: {
                    text: 'Total fruit consumption'
                },
                stackLabels: {
                    enabled: true,
                    style: {
                        fontWeight: 'bold',
                        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                    }
                }
            },
            legend: {
                align: 'right',
                x: -70,
                verticalAlign: 'top',
                y: 20,
                floating: true,
                backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
                borderColor: '#CCC',
                borderWidth: 1,
                shadow: false
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.x +'</b><br/>'+
                        this.series.name +': '+ this.y +'<br/>'+
                        'Total: '+ this.point.stackTotal;
                }
            },
            plotOptions: {
                column: {
                    stacking: 'normal',
                    dataLabels: {
                        enabled: true,
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                        style: {
                            textShadow: '0 0 3px black, 0 0 3px black'
                        }
                    }
                }
            }
        });
    });

所以极小的值显示在额外的标签上。

我甚至不确定highchart lib是否可以这样做,

请建议一些代码示例。欢呼声

1 个答案:

答案 0 :(得分:0)

不幸的是,这不是默认支持,但您可以尝试使用自适应解决方案来检测标签之间的冲突。

load: function() {
                    StaggerDataLabels(this.series);
                },
                redraw: function() {
                    var series = this.series;
                    setTimeout(function() {
                        StaggerDataLabels(series);
                    }, 1000);
                }

http://jsfiddle.net/menXU/6/

相关问题