2017-02-15 212 views
0

我想一個額外的Y軸添加到我的圖的右側。添加第二個Y軸

this example所描述的,我增加了一個附加的價值軸和位於其右邊:

{ 
    "id": "v2", 
    "position": "right" 
} 

但是它似乎只是被忽略。

這是我的全部代碼:

var chart = AmCharts.makeChart("mydia", { 
    "type": "xy", 
    "dataProvider": data, 
    "valueAxes": [{ 
    "id": "v1", 
    "position": "left" 
    }, { 
    "id": "v2", 
    "position": "right" 
    }], 
    "graphs": [{ 
    "balloonText": "x:[[x]] y:[[y]]", 
    "xField": "ax", 
    "yField": "ay", 
    }, { 
    "balloonText": "x:[[x]] y:[[y]]", 
    "xField": "bx", 
    "yField": "by", 
    }], 
}); 

任何人的想法?

Here is a fiddle

回答

2

你必須指定一個圖形到第二Y軸,否則他們將全部使用第一valueAxis。這是通過yAxis屬性XY圖表中完成:

"graphs": [{ 
    "balloonText": "x:[[x]] y:[[y]]", 
    "bullet": "round", 
    "xField": "ax", 
    "yField": "ay" 
    }, { 
    "balloonText": "x:[[x]] y:[[y]]", 
    "yAxis": "v2", //needs to be the ID or valueAxis object itself 
    "bullet": "round", 
    "xField": "bx", 
    "yField": "by" 
    }], 

請注意,您還需要有在使用第二y軸的圖表數據,也不會出現在所有。

這是你updated fiddle與第二圖形一些虛擬數據。