2016-09-30 28 views
0

私が望むように正しく動作するbarchartを作成しました。今、バーを重ねる線グラフを追加しようとしていますが、コードを実行すると線グラフが表示されますが、バーは消えます。線グラフを追加するのはかなりシンプルなようですが、なんらかの理由でうまくいきません。私はコンソールでも間違いがない。Plotly.js barchartに線グラフを追加すると棒が消えます

var x_text = ["Comodities","Consumer Discretionary","Utilities", 
       "Health & Biotech","Global Real Estate","Financials", 
       "Emerging Market Bonds","Technologies","Industrials", 
       "Oil & Gas","China Equities","S&P500"]; 
    //    
    var trace1 = [{ 

    x: x_text, // X axis (names) 
    y: zValues, // Values (y axis) 
    hoverinfo: zValues, 
    type: 'bar', 
    orientation:"v", 
    marker: { 
    color: color_list, // Color of bars 
    line: { 
     color: 'rbg(8,48,107)', 
     width: 1 
    }}, 
    yauto: false, 
    showscale: true, 
    }]; 

    var trace2 = { 
    x: x_text, 
    y: [-0.1,-0.1,2.3,3.3,1.0,0.4,0.9,3.0,-0.1,-1.4,3.0,0.2], 
    mode: 'lines', 
    line:{ 
    color:'black' 
    }, 
    type: 'scatter' 
}; 


    var layout = { 
    font:{ 
     // Text size and color 
     size:16, 
     family:'helvetica', 
     color: "white" 
    }, 
    annotations: arrow(), 
    xaxis: { 
     side: 'bottom', 
     orientation: "right" 
    }, 
    yaxis: { 
     autosize: true, 
     tickfont: "white", 
     ticksuffix: "%", 
     // Y axis scale 
     autorange: false, 
     range :[-20,20] 
    }, 
    // Graph position 
    margin: { 
    l: 90, 
    r: 90, 
    b: 120, 
    t: 20, 
    pad: 10 
    }, 
    // Graph background colors 
    paper_bgcolor: "transparent", 
    plot_bgcolor:"transparent", 
    }; 

var data = [trace1, trace2]; 

Plotly.newPlot('myDiv',data,layout); 

答えて

0

ああダムは、私のTRACE1はバーのために働いていた値が、周りにカッコ+中括弧を持っていましたが、linegraphが呼び出されたときにそれをdissappearました。

関連する問題