2014-03-28 25 views
0

我試圖讓兩條線使用兩個不同的比例。NVD3圖:使用muiltiChart /多個yScales繪製切換會導致軸消失,但不是繪圖

當我嘗試切換繪圖時,網格線消失,而不是圖。

你能弄清楚我做錯了什麼嗎?

http://jsfiddle.net/3ZP3S/

var dataset1 = { 
    values : [], 
    key : "Math.cos", 
    type: "line", 
    color: '#2ca02c', 
    yAxis: 1 
}; 

var dataset2 = { 
    values : [], 
    key : "sin", 
    type: "line", 
    color : "#ff7f0e", 
    yAxis: 2 
}; 

for (var i = -3.14; i < 3.1415; i+= .01){ 
    dataset1.values.push({ x: i , y : Math.cos(i) }); 
    dataset2.values.push({ x: i , y : Math.sin(i) * 3 }); 
} 

var data = [dataset1, dataset2]; 

nv.addGraph(function() { 
    var chart = nv.models.multiChart() 
    .margin({top: 30, right: 60, bottom: 50, left: 70}) 
    .color(d3.scale.category10().range()); 

    chart.xAxis 
    .tickFormat(d3.format(',.2f')); 

    chart.yAxis1 
    .tickFormat(d3.format(',.1f')); 

    chart.yAxis2 
    .tickFormat(d3.format(',.1f')); 

    d3.select('#chart svg') 
     .datum(data) 
     .transition().duration(500).call(chart); 

    return chart; 
}); 

Toggle is using the built in D3 toggle

+0

沒有做任何的反覆? –

+0

它使用內置的D3切換選項...我附加了一個圖像。謝謝。 – Derrick

+0

哦,我明白了。看起來像是一個NVD3的bug。 –

回答

1

這與nvd3的錯誤。我嘗試了幾個「以前」版本的nvd3和d3,而且這種情況一直在發生。

我們也決定放棄nvd3和開關C3.js,這似乎是「多」更在穩定性方面的成熟......

你的小提琴和代碼似乎