2015-08-25 2 views
0

Я чувствую, как ив попробовал все, но ничего не похоже на работу:Plotly установить цвет

  var charData = [{ 
        x: x1, 
        y: y, 
        type: 'bar', 
        color: 'rgb(31,119,180)', 
        orientation: 'h', 
        name: 'Nuværende', 
        bar: { 
         color: 'rgb(rgb(31, 114, 225)' 
        } 
       }, { 
        x: x2, 
        y: y, 
        type: 'bar', 
        orientation: 'h', 
        name: 'Forventet' 
       }], 
       layout = { 
        title: 'Brugere', 
        barmode: 'stack', 
        legend: { 
         orientation: 'h' 

        } 
       }; 
      Plotly.newPlot(area,charData,layout); 

Ive также пытались:

  var charData = [{ 
        x: x1, 
        y: y, 
        type: 'bar', 
        color: 'rgb(31,119,180)', 
        orientation: 'h', 
        name: 'Nuværende', 
        color: '#23b7e5' 
       }, { 
        x: x2, 
        y: y, 
        type: 'bar', 
        orientation: 'h', 
        name: 'Forventet' 
       }], 
       layout = { 
        title: 'Brugere', 
        barmode: 'stack', 
        legend: { 
         orientation: 'h' 

        } 
       }; 
      Plotly.newPlot(area,charData,layout); 

Однако карта остается с по умолчанию цвета.

Так как я могу изменить цвета с помощью Plotly?

ответ

2

Try:

var charData = [{ 
       x: x1, 
       y: y, 
       type: 'bar', 
       orientation: 'h', 
       name: 'Nuværende', 
       marker: { 
        color: '#23b7e5' 
       } 
      }], 
      layout = { 
       title: 'Brugere', 
       barmode: 'stack', 
       legend: { 
        orientation: 'h' 

       } 
      }; 
     Plotly.newPlot(area,charData,layout); 

Другой пример here.