2013-07-29 44 views
0

我试图用一些系列在LHS轴(“Y”)显示给创建的线图和在RHS轴线一些系列(“其他y”)的图表:道场具有多个轴

//Init chart and set theme 
var myChart = new Chart("graphDiv") 
myChart.setTheme(theme) 

//Add plot for LHS axis 
myChart.addPlot("default", { 
    type: Lines, 
    markers: true, 
    hAxis: "x", 
    vAxis: "y" 
}) 

//Add additional plot for RHS axis 
myChart.addPlot("other", { 
    type: Lines, 
    markers: true, 
    hAxis: "x", 
    vAxis: "other y" 
}) 

//Add axis 
myChart.addAxis("x", { 
    fixUpper: "major", 
    fixLower:"minor" 
}) 
myChart.addAxis("y", { 
    title: "Y Axis Left", 
    vertical: true, 
    fixUpper: "major", 
    fixLower:"minor" 
}) 
myChart.addAxis("other y", { 
    title: "Y Axis Right", 
    vertical: true, 
    leftBottom: false, 
    fixUpper: "major", 
    fixLower:"minor", 
}) 

//Add the data 
myChart.addSeries('test1',[{x:1,y:2},{x:2,y:2},{x:3,y:2},{x:4,y:2}],{plot:'default'}) 
myChart.addSeries('test2',[{x:1,y:3},{x:2,y:3},{x:3,y:3},{x:4,y:3}],{plot:'default'}) 
myChart.addSeries('test3',[{x:1,'other y':5},{x:2,'other y':5},{x:3,'other y':5}, x:4,'other y':5}],{plot:'other'}) 
myChart.render() 

第二个轴未呈现,第二个绘图(“其他”)的数据未呈现。但是,如果我可以在myChart.series中看到所有数据都在那里!在控制台窗口中没有错误,我正在使用Dojo 1.9和chrome。

ahhh!

任何想法我做错了吗?

回答

2

将您的数据字段“other y”设置为“y”,如同在其他图中。该属性对应的轴是x或y,而不是轴名称。即你的第三个系列应该是:

myChart.addSeries('test3',[{x:1,y:5},{x:2,y:5},{x:3,y:5}, {x:4,y:5}],{plot:'other'}) 

我的动画,在这个例子系列所以它脱颖而出:http://jsfiddle.net/psoares/nYtAg/

+0

请注意,由当你定义第二轴去除最大值和最小值参数,这导致轴不被渲染。这是一个错误? – en51nm

+0

它适用于我...看到http://jsfiddle.net/psoares/nYtAg/20/ – Philippe