改变数据在高图中的显示方式

Changing the way the data is shown in Highcharts

本文关键字:显示方式 高图中 数据 改变      更新时间:2023-09-26

我有一个小问题,我有一个由highcharts生成的饼状图-它以百分比表示数据。例如,如果我有两个值2和3,它会在图表上显示40%和60%。我不想用百分比来显示数据,我想用图表2和3来显示这些数字。有人知道我要怎么做才能显示数字而不是百分比吗?谢谢!

chart: 
        {
            renderTo: 'sunshine',
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: 
        {
            text: 'Browser market shares at a specific website, 2010'
        },
        tooltip: 
        {
            pointFormat: '{series.name}: <b>{point.percentage}%</b>',
            percentageDecimals: 1
        },
        plotOptions: 
        {
            pie: 
            {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: 
                {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    formatter: function() 
                    {
                        return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                    }
                }
            }
        },
        series: [
        {
            type: 'pie',
            name: 'Browser share',
            data: [
                ['Jan',   2],
                ['Feb',       3],
            ]
        }]
    });

使用pie属性的标签格式化器。您可以使用this.y值访问精确的数据点:

 pie: 
        {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: 
            {
                enabled: true,
                color: '#000000',
                connectorColor: '#000000',
                formatter: function() 
                { 
                    return '<b>'+ this.point.name +'</b>: '+ this.y;
                }
            }
        }