d3js x刻度上的最大值和最小值。

时间:2014-05-27 14:07:17

标签: d3.js nvd3.js

我想控制使用d3js制作的此图表上x刻度的最大值和最小值。 该图由以下代码构成:

    nv.addGraph(function() {
        var chart = nv.models.twoLinesWithFocusChart()
            .x(function(d) {
                return d[0]
            })
            .y(function(d) {
                return d[1]
            })
            .clipEdge(true);

        chart.xAxis
            .orient("bottom") // this adds a label to the axis
            .tickFormat(function(d) {
                return d3.time.format('%d/%m/%y')(new Date(d))
            });

        chart.yAxis
            .axisLabel('Values:') // this adds a label to the axis
            .tickFormat(d3.format('d'));

        chart.x2Axis
            .tickFormat(function(d) {
                return d3.time.format('%d/%m/%y')(new Date(d))
            });

        d3.select('#' + svgChartId + ' svg')
            .datum(data)
            .transition().duration(500).call(chart);


        nv.utils.windowResize(chart.update);


        return chart;
    });

祝你好运。

1 个答案:

答案 0 :(得分:0)

使用相似的问题here: -

xScale.domain([minValue,maxValue]);

或者您可以尝试使用: -

chart.forceX([minValue,maxValue]);

希望它有所帮助。

相关问题