在工具提示高图上显示百分比 Angular 2

bla*_*mon 2 javascript highcharts angular

您好,我有以下用于带有百分比值的普通柱形图的高图表配置。

private _attendanceInputData: any = {

        chart: { type: 'column' },
        title : { text : 'Daily Attendance Overview' },  

        xAxis: {
            categories: this._weekValues
        },
        yAxis: {
            allowDecimals: false,
            title: { text: ''},
            min: 0,
            max: 100,
            labels: {
                formatter:function() {
                    console.log(this.value); //0, 25, 50 , 75 , 100
                    var pcnt = (this.value / 100) * 100;
                    return pcnt + '%';
                }
            }
        },
        credits: {
          enabled: false
        },
        series: [
            {
                name: 'Students',
                data: this._studentAttendance,
                color: '#3366cc'
            },{
                name: 'Staff',
                data: this._staffAttendance,
                color: '#accbfc',
            }
        ]
    };
Run Code Online (Sandbox Code Playgroud)

但工具提示现在显示值,但在值后不显示“%”。怎么做?抱歉,我是 highcharts 新手。预先感谢各位。

Mar*_*der 5

您需要告诉 Highcharts 工具提示的格式。为此,tooltiphighcharts 对象中有一个部分。要在每个值后面呈现“%”,您可以使用以下代码片段:

[...]
credits: {
  enabled: false
},
tooltip: {
  valueSuffix: '%'
},
series: [{
[...]
Run Code Online (Sandbox Code Playgroud)

请参阅http://api.highcharts.com/highcharts/tooltip以供参考