2013-07-29 48 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