如何修改多栏图表获取“错误:<path>属性转换的无效值=”翻译(NaN,NaN)“”?

时间:2017-02-04 17:49:48

标签: angularjs d3.js nvd3.js

var dayToDateConverter = function (day) {
        var mSec = day * 24 * 60 * 60 * 1000;
        var m = moment(mSec).utc();

        if (m.format("MM/DD/YY") === 'Invalid Date') {
            return;
        }
        return m.format("MM/DD/YY");
    };




CUSTOMERTRACGRAPH: {
            "options": {
                chart: {
                    type: 'multiBarChart',
                    grouped: true,
                    showControls: false,
                    height: 400,
                    color: ["#f4a460", "#d27b6f"],
                    margin: {
                        top: 20,
                        right: 20,
                        bottom: 60,
                        left: 45
                    },
                    clipEdge: true,
                    staggerLabels: true,
                    transitionDuration: 1000,
                    tooltips: true,
                    tooltipContent: function (key, x, y, e, graph) {
                        return '<p>' + key + ': ' + y + '</p>';
                    },
                    xAxis: {
                        axisLabel: 'Date (MM/DD/YY)',
                        axisLabelDistance: 10,
                        showMaxMin: true,
                        tickFormat: function (d) {
                            return d;
                        }
                    },
                    yAxis: {
                        axisLabel: 'Count',
                        axisLabelDistance: -20,
                        tickFormat: function (d) {
                            return d3.format(',.f')(d);
                        }
                    }
                },
                data: []
            }

数据格式如下:[ {"key":"New","values":[{"x":17136,"y":5178}]}, {"key":"Returning","values":[{"x":17136,"y":0}]} ] 我正在调用一些API,并且在它的成功回调中我正在填充图表的数据并收到此错误:

  

错误:属性变换的值无效=“translate(NaN,NaN)”

有没有可能解决这个错误的解决方案?

提前致谢

0 个答案:

没有答案