javascript - Plotly set color - Stack Overflow

I feel like ive tried everything but nothing seem to work:var charData = [{x: x1,y: y,type: 'bar&#

I feel like ive tried everything but nothing seem to work:

            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 also tried:

            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);

However the chart stays with default colors.

So how can i change colors using Plotly?

I feel like ive tried everything but nothing seem to work:

            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 also tried:

            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);

However the chart stays with default colors.

So how can i change colors using Plotly?

Share Improve this question asked Aug 25, 2015 at 14:05 Marc RasmussenMarc Rasmussen 20.6k83 gold badges223 silver badges384 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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);

Another example here.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744282241a4566626.html

相关推荐

  • javascript - Plotly set color - Stack Overflow

    I feel like ive tried everything but nothing seem to work:var charData = [{x: x1,y: y,type: 'bar&#

    8天前
    70

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信