nvd3 multiBarChart未显示x轴

时间:2015-10-09 14:12:43

标签: nvd3.js

您好我试图创建一个nvd3多栏图但我无法获得x轴显示。 我在网上搜索但找不到我的问题的解决方案。 这里是完整的代码请帮忙。我还附加了一个pix输出。谢谢!

 <script>
 function data0() {
     var a0 = [],
     a1 = [];


a0.push({ x: 1, y: 5065});
a0.push({ x: 2, y: 11464});
a0.push({ x: 3, y: 200});
a0.push({ x: 4, y: 100});
a0.push({ x: 5, y: 0});
a0.push({ x: 6, y: 0});
a0.push({ x: 7, y: 100});
a0.push({ x: 8, y: 2200});
a0.push({ x: 9, y: 2200});
a0.push({ x: 10, y: 0});
a0.push({ x: 11, y: 0});
a0.push({ x: 12, y: 0});
a0.push({ x: 13, y: 0});
a0.push({ x: 14, y: 0});

a1.push({ x: 1, y: 148});
a1.push({ x: 2, y: 2966});
a1.push({ x: 3, y: 1200});
a1.push({ x: 4, y: 79});
a1.push({ x: 5, y: 0});
a1.push({ x: 6, y: 0});
a1.push({ x: 7, y: 0});
a1.push({ x: 8, y: 2185});
a1.push({ x: 9, y: 2185});
a1.push({ x: 10, y: 0});
a1.push({ x: 11, y: 0});
a1.push({ x: 12, y: 0});
a1.push({ x: 13, y: 0});
a1.push({ x: 14, y: 0});



            return [
                    {
                        values: a1,
                        key: 'Queue',
                        color: '#04B45F'
                    },
                    {
                        values: a0,
                        key: 'In Progress',
                        color: '#DBA901',
                        area: true
                    }
            ];
        }
        nv.addGraph(function () {

            var chart = nv.models.multiBarChart()
                    .margin({ left: 65, right: 40, bottom: 45 })
                    .stacked(true)
                    .showControls(false)
            ;


            chart.xAxis
                .axisLabel("Daily")
                .rotateLabels(0)
                .tickValues([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
                .tickSize(12)
                .showMaxMin(false)
                .tickFormat(function (d) {
                    var _tools = ["", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"]
                    return _tools[d]
            });




            chart.yAxis
                .axisLabel("Number of[enter image description here][1]")
                .tickFormat(d3.format(',.0f'));

            d3.select('#BarChart-Cell svg')
            .datum(data0)
            .transition()
            .duration(500)
            .call(chart)
            ;

            nv.utils.windowResize(chart.update);

            return chart;
        });
    </script>

[http://i.stack.imgur.com/HNNJf.png]

0 个答案:

没有答案