NVD3多条水平图x轴域 [英] NVD3 multi bar horizontal chart x axis domain

查看:391
本文介绍了NVD3多条水平图x轴域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用nvd3将我的网域设为[0,400]?这是我的代码:

How can I set my domain to [0,400] with nvd3? Here is my code:

var chart;
nv.addGraph(function() {
    chart = nv.models.multiBarHorizontalChart().x(function(d) {
        return d.label
    }).y(function(d) {
        return d.value
    }).margin({
        top : 30,
        right : 20,
        bottom : 50,
        left : 175
    }).barColor(d3.scale.category20().range()).transitionDuration(250).stacked(true)

    chart.yAxis.tickFormat(d3.format(',.2f'));

    d3.select('#chart1 svg').datum(long_short_data).call(chart);

    nv.utils.windowResize(chart.update);

    chart.dispatch.on('stateChange', function(e) {
        nv.log('New State:', JSON.stringify(e));
    });

    return chart;
}); 


推荐答案

您可以使用 xDomain yDomain 取决于您的轴要求,最后

You could use xDomain or yDomain depending on you axis requirement and finally

chart.xDomain([0,400])

如果你想玩yAxis上的范围,你可以尝试

If you want to play around with the ranges on the yAxis you could try

chart.forceY([0, 400]); or chart.forceX([0, 400]);

希望它有帮助。

这篇关于NVD3多条水平图x轴域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆