D3.js 在nvd3中为discreteBarChart指定xDomain会导致图表不正确

D3.js 在nvd3中为discreteBarChart指定xDomain会导致图表不正确,d3.js,graph,nvd3.js,D3.js,Graph,Nvd3.js,当我尝试在不指定xDomain的情况下绘制discreteBarChart时,输出如下: 而当我使用指定xDomain打印discreteBarChart时,输出如下: 以下是我用来指定图表选项的代码: chart: { type: "discreteBarChart", height: 350, margin : { top: 20,

当我尝试在不指定xDomain的情况下绘制discreteBarChart时,输出如下:

而当我使用指定xDomain打印discreteBarChart时,输出如下:

以下是我用来指定图表选项的代码:

       chart: {
                type: "discreteBarChart",
                height: 350,
                margin : {
                    top: 20,
                    right: 20,
                    bottom: 50,
                    left: 65
                },
                x: function(d){ return d['x']; },
                y: function(d){ return d['y']; },

                xAxis: {
                    axisLabel:  xAxisLabel,                        
                    showMaxMin: false,
                    axisLabelDistance: 2
                },

                yAxis: {
                    axisLabel: yAxisLabel,                        
                    axisLabelDistance: 0,
                },
                legend: {margin: {top: 5}},
                xDomain:[xLowerLimit,xUpperLimit] /* This is where the problem is */
            },
            title: {
                enable :true,
                text: chartTitle
            }
有人能帮我理解为什么我在指定xDomain时会得到如此混乱的discreteBarChart图吗

我使用的是NVD31.8.5


我发现这个链接(https://github.com/krispo/angular-nvd3/issues/264)处理linePlusBarChart的类似问题。该链接中提到的解决方案是使用“xDomain”相关代码编辑nvd3源文件。为了尝试同样的方法,我查看了源代码,但发现xDomain部分用于discreteBarChart对我的眼睛有好处

您可以创建一个plunkr/jsfiddle吗?不确定您想用xDomain实现什么?虽然此链接可以回答问题,但最好在此处包含答案的基本部分,并提供链接供参考。如果链接页面发生更改,仅链接的答案可能无效。-@garyh在LQPRQ中复习时请小心!这篇文章甚至没有链接。
  chart: {
            type: "discreteBarChart",
            height: 350,
            margin : {
                top: 20,
                right: 20,
                bottom: 50,
                left: 65
            },
            x: function(d){ return d['x']; },
            y: function(d){ return d['y']; },

            xAxis: {
                axisLabel:  xAxisLabel,                        
                showMaxMin: false,
                axisLabelDistance: 2
            },

            yAxis: {
                axisLabel: yAxisLabel,                        
                axisLabelDistance: 0,
            },
            legend: {margin: {top: 5}},
            forceX: [xLowerLimit,xUpperLimit]
        },
        title: {
            enable :true,
            text: chartTitle
        }