顶部的高位y轴单位

时间:2018-05-25 07:32:46

标签: javascript highcharts axis-labels yaxis

我想在y轴上添加y轴单位。

现在我可以使用标签格式化程序并将最后一个标签作为单位。它工作正常,直到我在y轴上只有一个标签。然后我明白了:

enter image description here

我想得到这个:

enter image description here

你知道如何获得它吗?

Jsfiddle:http://jsfiddle.net/ptbtvozb/2/

代码在这里:

Highcharts.chart('container', {
    yAxis: {
        labels: {
            formatter: function() {
                var unit = 'pop';
                if(this.isLast) {
                    return unit;
                } else {
                    return this.value;
                }
            }
        },
        tickInterval: 1,
        title: { text: "RQ-online" }
    },
    series: [{
        data: [[0, 1],[1, 1],[2, 1]]
    }]
});

1 个答案:

答案 0 :(得分:2)

使用yAxis.title

Sub ConcatData()
Dim X As Double
Dim DataArray(5000, 2) As Variant
Dim NbrFound As Double
Dim Y As Double
Dim Found As Integer
Dim NewWks As Worksheet

Cells(1, 1).Select
Let X = ActiveCell.Row
Do While True
If Len(Cells(X, 1).Value) = Empty Then
Exit Do
End If
If NbrFound = 0 Then
NbrFound = 1
DataArray(1, 1) = Cells(X, 1)
DataArray(1, 2) = Cells(X, 2)
Else
For Y = 1 To NbrFound
Found = 0
If DataArray(Y, 1) = Cells(X, 1).Value Then
DataArray(Y, 2) = DataArray(Y, 2) & ", " & Cells(X, 2)
Found = 1
Exit For
End If
Next
If Found = 0 Then
NbrFound = NbrFound + 1
DataArray(NbrFound, 1) = Cells(X, 1).Value
DataArray(NbrFound, 2) = Cells(X, 2).Value
End If
End If
X = X + 1
Loop

Set NewWks = Worksheets.Add
NewWks.Name = "SummarizedData"
Cells(1, 1).Value = "Names"
Cells(1, 2).Value = "Results"
X = 2
For Y = 1 To NbrFound
Cells(X, 1).Value = DataArray(Y, 1)
Cells(X, 2).Value = DataArray(Y, 2)
X = X + 1
Next
Beep
MsgBox ("Summary is done!")
End Sub

直播示例:http://jsfiddle.net/akLc93mh/