首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >高图表叠加百分比列图能否小于100%?

高图表叠加百分比列图能否小于100%?
EN

Stack Overflow用户
提问于 2016-03-18 17:38:38
回答 2查看 1.5K关注 0票数 0

我有一个要求,有一个堆叠百分比列图表,在高图表显示一个具体的百分比数字,而不是一个100%的细分。例如,如果数字是60%,图表应该显示一个60%的细分(20%蓝色,10%绿色,30%黄色),而不是填补高达100%。我对百分比图表的理解是,它们总是100%,但我想知道这种操纵是否可以用高图表来实现?谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-18 18:19:19

就像@Alden所说的那样,使用带有%标签的堆叠列。这是JSFiddle实例

代码语言:javascript
复制
$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        title: {
            text: 'Stacked column chart'
        },
        xAxis: {
            categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] 
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Percentage'
            },
            labels: {
                formatter: function () {
                    return this.value + '%';
                }
            },
            stackLabels: {
                enabled: true,
                style: {
                    fontWeight: 'bold',
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                },
                formatter: function () {
                    return this.total + '%';
                }
            }
        },
        legend: {
            align: 'right',
            x: -30,
            verticalAlign: 'top',
            y: 25,
            floating: true,
            backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white',
            borderColor: '#CCC',
            borderWidth: 1,
            shadow: false
        },
        tooltip: {
            headerFormat: '<b>{point.x}</b><br/>',
            pointFormat: '{series.name}: {point.y}%<br/>Total: {point.stackTotal}%'
        },
        plotOptions: {
            column: {
                stacking: 'normal',
                dataLabels: {
                    enabled: true,
                    format:'{y}%',
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
                    style: {
                        textShadow: '0 0 3px black'
                    }
                }
            }
        },
        series: [{
            name: 'John',
            data: [5, 3, 4, 7, 2]
        }, {
            name: 'Jane',
            data: [2, 2, 3, 2, 1]
        }, {
            name: 'Joe',
            data: [3, 4, 4, 2, 5]
        }]
    });
});
票数 0
EN

Stack Overflow用户

发布于 2016-03-18 18:14:53

使用堆叠列而不是堆叠百分比列,然后简单地将百分比附加到标签中。“百分比”列自动确定所提供的所有数据点的百分比,听起来您希望该列只是呈现所提供的信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36090890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档