2014-04-07 105 views
0

我正嘗試創建一個帶有兩個軸和兩個數據系列的簡單圖表。dimple.js多系列**線**圖表

當我定義泡系列 - 但預期當兩個系列被定義爲線的所有作品,從數據點到y軸的虛線感到困惑

出人意料的是,我不是不能似乎可以找到任何顯示帶2 *線系列的2 * y軸的例子。

我的X軸是基於時間,但我可以使用以前的jsfiddle答案(jsfiddle.net/NCW89/)說明問題:

var svg = dimple.newSvg("#chartContainer", 600, 400), 
chart = null, 
s1 = null, 
s2 = null, 
x = null, 
y1 = null, 
y2 = null; 

chart = new dimple.chart(svg); 
x = chart.addCategoryAxis("x", "Fruit"); 
y1 = chart.addMeasureAxis("y", "Value"); 
y2 = chart.addMeasureAxis("y", "Value"); 
s1 = chart.addSeries("Year", dimple.plot.bubble, [x, y1]); 
s1.data = [ 
     { "Value" : 100000, "Fruit" : "Grapefruit", "Year" : 2012 }, 
     { "Value" : 400000, "Fruit" : "Apple", "Year" : 2012 }, 
     { "Value" : 120000, "Fruit" : "Banana", "Year" : 2012 } 
    ]; 
s2 = chart.addSeries("Year", dimple.plot.bubble, [x, y2]); 
s2.data = [ 
     { "Value" : 110000, "Fruit" : "Grapefruit", "Year" : 2013 }, 
     { "Value" : 300000, "Fruit" : "Apple", "Year" : 2013 }, 
     { "Value" : 140000, "Fruit" : "Banana", "Year" : 2013 } 
    ]; 
chart.draw(); 

改變從dimple.plot.bubble系列 - >酒窩.plot.line將顯示行爲。

似乎這樣一個常見的必需功能,我不禁感到我失去了明顯的東西。

謝謝

回答

1

恐怕你不會錯過任何東西它是最近版本中引入的錯誤。我會在接下來的一週或兩週內發佈1.2版本。不幸的是,破解版本也增加了設置系列特定數據的能力。如果你想工作在此期間,圍繞你需要回去1.1.3版本,並設定您的數據的老式方法:

var svg = dimple.newSvg("#chartContainer", 600, 400), 
    chart = null, 
    s1 = null, 
    s2 = null, 
    x = null, 
    y1 = null, 
    y2 = null, 
    data = [ 
     { "Fruit" : "Grapefruit", "Value 1" : 100000, "Year 1" : 2012, "Value 2" : 110000, "Year 2" : 2013 }, 
     { "Fruit" : "Apple", "Value 1" : 400000, "Year 1" : 2012, "Value 2" : 300000, "Year 2" : 2013 }, 
     { "Fruit" : "Banana", "Value 1" : 120000, "Year 1" : 2012, "Value 2" : 140000, "Year 2" : 2013 } 
]; 

chart = new dimple.chart(svg, data); 
x = chart.addCategoryAxis("x", "Fruit"); 
y1 = chart.addMeasureAxis("y", "Value 1"); 
y2 = chart.addMeasureAxis("y", "Value 2"); 
s1 = chart.addSeries("Year 1", dimple.plot.line, [x, y1]); 
s2 = chart.addSeries("Year 2", dimple.plot.line, [x, y2]); 
chart.draw(); 

http://jsfiddle.net/NVV9r/1/

+0

啊,感謝information.not多回到1.1.3的問題 - 非常有幫助,謝謝 – user3506975