簡體   English   中英

高圖Y軸標簽

[英]Highcharts Y-axis labels

這是我的圖形當前的外觀: 在此處輸入圖片說明

如何將Y軸上的值更改為等於您在工具提示中看到的名稱,即“其他問題”,我希望此名稱代替當前出現的數值Y軸

這是我的代碼:

 function BarChartCategory() {

        var arr =  @Html.Raw(Json.Encode(@ViewBag.Categories));

        console.log(arr);

        var RNames = [], RValues = [], prev;

        //Count how many occurances of each value
        arr.sort();
        for ( var i = 0; i < arr.length; i++ ) {
            if ( arr[i] !== prev ) {
                RNames.push(arr[i]);
                RValues.push(1);
            } else {
                RValues[RValues.length-1]++;
            }
            prev = arr[i];
        }

        console.log(RValues);
        console.log(RNames);

        var final = [];

        for(var i=0; i < RNames.length; i++) {
            final.push({
                name: RNames[i],
                y: RValues[i]
            });
        }

        console.log(final);


        $('#container').highcharts({
            chart: {
                type: 'bar'
            },
            title: {
                text: 'By Category Results'
            },
            yAxis: {
                allowDecimals: false,

            },
            tooltip: {
                formatter: function () {
                    return '<b>' + this.series.name + '</b><br/>' +
                        this.point.y + ' ' + this.point.name.toLowerCase();
                }
            },
            series: [{
                name: "Issues: ",
                colorByPoint: true,
                data: final
            }]
        });
    }

我能夠找到問題的解決方案,我首先將Yaxis更改為xaxis,並添加了遍歷數組中每個結果的循環

xAxis: {
                allowDecimals: false,

                categories: function(){
                    var data
                    for(var i=0;i< final.length;i++){
                        data.push({
                            categories: final[i].name
                        })
                    };
                    return data;
                }

            }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM