【问题标题】:Highchart stacked bar yAxis stacked label issueHighchart堆叠条yAxis堆叠标签问题
【发布时间】:2018-05-29 18:54:30
【问题描述】:

这里是js小提琴highchart stacked bar stacked label issue

Highcharts.chart('container', {
    chart: {
        type: 'bar'
    },
    title: {
        text: 'Stacked bar chart'
    },
    xAxis: {
        categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
    },
    yAxis: {
        min: 0,
        title: {
            text: 'Total fruit consumption'
        },
        stackLabels: {
          enabled: true,
          align: 'right',
          style: {
            color: '#838383',
            fontSize:"12px",
            fontWeight:"normal",
            width:'60px'
          }
        }
    },
    legend: {
        reversed: true
    },
    plotOptions: {
        series: {
            stacking: 'normal'
        }
    },
    series: [{
        name: 'John',
        data: [5555555555555, 3, 4, 7, 2]
    }, {
        name: 'Jane',
        data: [2, 2, 3, 2, 1]
    }, {
        name: 'Joe',
        data: [3, 4, 4, 2, 5]
    }]
}); 

是否可以设置条的最大长度以使 yAxis 标签不隐藏?或者我怎样才能显示完整的标签?目前如果它的值很大,它会隐藏标签的某些部分。

【问题讨论】:

  • 将 stackLabels.style.whiteSpace 设置为 'nowrap' 并将 chart.style.overflow 设置为可见 - 此设置允许查看溢出的标签 jsfiddle.net/35reh42o。您还可以将最大值设置为高于您的最大数据值。

标签: highcharts label stacked-chart


【解决方案1】:

您需要像这样设置align

    labels: {
        align:'right'
    }

Fiddle

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    相关资源
    最近更新 更多