簡體   English   中英

從次要Y軸上的值中刪除減號(Nvd3-Multibar水平圖)

[英]To remove minus sign from the values on the secondary Y-axis (Nvd3 -Multibar Horizontal Chart)

我想擺脫次級y軸的負號。 下圖顯示了相同的情況。 Nvd3多欄水平圖

碼:

var app = angular.module('myApp', ['nvd3']);
app.controller('myCtrl', function($scope) {


    $scope.options = {
        chart: {
            type: 'multiBarHorizontalChart',
            height: 350,
            x: function(d){
                console.log(d.value);
                return d.label;},
            y: function(d){return d.value;},
            //yErr: function(d){ return [-Math.abs(d.value * Math.random() * 0.3), Math.abs(d.value * Math.random() * 0.3)] },
            showControls: true,
            showValues: true,
            duration:"500",
            stacked: true,
            xAxis: {
              showMaxMin: false

            },
            axisLabelDistance:50,
            yAxis: {
                axisLabel: 'Values',
                tickFormat: function(d){
                    return d3.format(',f')(Math.abs(d));
                }
            },
            valueFormat:d3.format(".0f"),

        },

    };

我已經刪除了x軸值的負號,但是機器人能夠從輔助y軸中將其刪除。 請幫助我。

您應該能夠使用valueFormat屬性將條形值的格式設置為與yAxis的刻度值大致相同:

$scope.options = {
    chart: {
        /* more lines omitted for brevity */

        yAxis: {
            axisLabel: 'Values',
            tickFormat: function(d){
                return d3.format(',f')(Math.abs(d));
            }
        },
        valueFormat: function(d){
                return d3.format(',f')(Math.abs(d));
        },

        /* more lines omitted for brevity */
    },

};

暫無
暫無

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

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