在人力车图表中显示X和Y轴

时间:2013-04-19 06:31:28

标签: javascript charts rickshaw

我有多个数据及其计数。我想用人力车条形图显示它。如何分别在X和Y轴上显示数据和计数。我得到的只是:

var graph = new Rickshaw.Graph({
    element: document.querySelector("#chart"),
    renderer: 'bar',
    series: [{
        data: [ { x: 0, y: 40 }, { x: 1, y: 49 }, { x: 2, y: 12 }, { x: 3, y: 81 }, { x: 4, y: 40 }, { x: 5, y: 49 }, { x: 6, y: 12 },{ x:7, y: 12 }],
        color: 'steelblue'
    }]
});

graph.render();

显示没有X轴和Y轴的条形图。如何在条形图中显示X和Y轴?

2 个答案:

答案 0 :(得分:1)

来自rickshaw page on ShutterStock

var xAxis = new Rickshaw.Graph.Axis.Time({
    graph: graph
});

xAxis.render();

var yAxis = new Rickshaw.Graph.Axis.Y({
    graph: graph
});

yAxis.render();

答案 1 :(得分:0)

有关如何使用x和y轴进行图表的深入截屏,包括使用人力车进行缩放和平移(在AngularJS中),请转到:http://tagtree.io/d3-with-rickshaw-and-angular