2016-09-30 11 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 만 줄 근무 값, 주변에 중괄호 + 중괄호 있었지만 선 그래프가 호출되었을 때를 dissappear했다.

관련 문제