Javascript 绘图设置颜色
我觉得我什么都试过了,但似乎都不管用:Javascript 绘图设置颜色,javascript,plotly,Javascript,Plotly,我觉得我什么都试过了,但似乎都不管用: var charData = [{ x: x1, y: y, type: 'bar', color: 'rgb(31,119,180)', orientation: 'h', name: 'Nuv
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);
我也试过:
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);
但是,图表将保留默认颜色
那么如何使用绘图更改颜色呢?
试试:
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);
另一个例子