【问题标题】:X-axis labels overlap NVD3X 轴标签重叠 NVD3
【发布时间】:2016-09-14 09:19:01
【问题描述】:

我在我的应用程序中使用 NVD3 图表。我不明白为什么 X 轴标签在我的图表中重叠。有人可以帮我解决吗?

我曾尝试使用.ticks(3) 设置滴答数,但似乎不会影响滴答数。

        nv.addGraph(function () {
                var chart = nv.models.lineChart()
                        .x(function (d) {
                            return d[0];
                        })
                        .y(function (d) {
                            return d[1];
                        })
                        .showXAxis(true)
                        .showYAxis(false)
                        .useInteractiveGuideline(true);

                chart.xAxis     //Chart x-axis settings
                        .axisLabel('Time')
                        .tickFormat(function (d) {
                            var dateTimeFormat = '%m/%d/%Y %H:%M';
                            d = new Date(d);
                            return d3.time.format(dateTimeFormat)(d);

                        });
                chart.yAxis
                        .axisLabel('Size');
                chart.forceY([0]);

                d3.select('#id svg')
                        .datum(graphData)
                        .call(chart);

                nv.utils.windowResize(chart.update);

                return chart;
            });

【问题讨论】:

    标签: javascript jquery nvd3.js


    【解决方案1】:

    我正在使用 Angular-nvD3,我们可以使用 wrapLabels:true 来避免重叠问题。

    图表配置示例。

    vm.options = {
            chart: {
                type: 'discreteBarChart',
                x: function(d){return d.label;},
                y: function(d){return d.value;},
                wrapLabels:true
            }
        };
    

    屏幕截图:

    【讨论】:

      猜你喜欢
      • 2014-04-30
      • 2017-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-01
      • 2012-11-11
      相关资源
      最近更新 更多